-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Ivar value within struct not changing when using &->
#10035
Comments
A copy of the struct is passed, please don't do that. I won't revert my change. Just use a regular block. |
we should document the behavior of procs, basically saying what they rewrite to. In fact, I would like to remove this anti feature because it's redundant, except for taking the pointer of C functions |
and this: values.each &->add_value(Int32) Could be this: values.each &add_value(&1) and that would work well because it's just a regular block I don't understand why you (or others) use the more complex syntax. What's wrong with using a block with an argument and passing it inside the block? |
What I'm saying is, I never use that proc notation myself. It feels off. |
I'm not sure anybody realized |
What do you mean? |
Where does this syntax come from? It doesn't work on 0.35: https://carc.in/#/r/a26o (also not in the argless version) |
It's in my ideal version of the language, where #9218 and many others are merged. |
Ah, then
was worded a bit misleading :) At least to me it sounded like it's an alternative already. |
I meant, instead of: values.each &->add_value(Int32) write this: values.each { |value| add_value(value) } It's a bit longer, yes... but someone reading the code won't stop and wonder what's that |
That makes sense. I'm not too bothered by it, in my actual use case this made me notice the type should have been a class anyway (missed updating this one). At the least I'd maybe mark #9972 as a breaking change given the semantics of |
Makes sense. Done! |
Going to close this then as it's intended behavior. |
Not sure if this is intended or not but after #9972, changing the value of an ivar within a struct using
&->
proc notation causes the ivar's value to not actually change.On
0.35.1
:Container(@answer=true)
, while on master:Container(@answer=false)
.@asterite You guessed correctly haha
The text was updated successfully, but these errors were encountered: