-
-
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
Strip quesitonmark from query method in assignment #360
Comments
This is interesting. Right now when you do: hash[key] ||= value it gets rewritten to: hash[key]? || (hash[key] = value) While when you do: obj.property ||= value it gets rewritten to: obj.property || (obj.property = value) There is a small inconsistency here, but the object implementing So, we can leave things as they are and make: obj.property? ||= value be rewritten to: obj.property? || (obj.property = value) That way we cover all cases. I'm not sure this is what you are suggesting. I would forbid writing To make it even more consistent, one would have to write |
It's sort of what I'm suggesting yes, I think it could be more intuitive by letting the compiler check whether there's |
@jhass I think we can do that. But right now the syntax sugar is expanded by the parser, so we'd have to change that to expand it in the semantic phase. I don't see why we shouldn't do that: the smarter the compiler and the less the user has to choose what's the obvious correct way to do things, the better. Then we wouldn't even need that The only "issue" is if |
I don't think this should be driven by semantics. That would change the behaviour when a matching method is added in otherwise unrelated code. I experienced this issue in combination with |
This is a feature suggestion.
Suppose the following code:
This should actually call
obj.foo=(bar)
and notobj.foo?= (bar)
. Why? Because then you can write the following:Whether this is accepted or not, I think we should disallow methods ending in
?=
.The text was updated successfully, but these errors were encountered: