Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass arguments to spawn #2962

Closed
kostya opened this issue Jul 6, 2016 · 2 comments
Closed

pass arguments to spawn #2962

kostya opened this issue Jul 6, 2016 · 2 comments

Comments

@kostya
Copy link
Contributor

kostya commented Jul 6, 2016

would be nice if this works:

x = rand < 0.5 ? 1 : nil

spawn(args: {x}) do |x|
  p(x + 1) if x
end

p(x + 1) if x 

sleep 0.1

because right now i cant just compare with if x, i should write this, which is noise in big code:

x = rand < 0.5 ? 1 : nil

spawn do
  if y = x
    p y + 1
  end
end

if y = x
  p y + 1
end

sleep 0.1
@asterite
Copy link
Member

asterite commented Jul 6, 2016

I think the compiler should just be a bit smarter and notice that x doesn't change, so if x should just work

@asterite
Copy link
Member

asterite commented Aug 4, 2016

Closing as duplicate of #3093 (which describes the problem in a better way)

@asterite asterite closed this as completed Aug 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants