I've been using ruby for a decade and I don't get why this is necessary (or even good).
Ruby adds experimental support for Rightward assignments
11–20 of 39 posts
Re: Ruby adds experimental support for Rightward assignments
#12Re: Ruby adds experimental support for Rightward assignments
#13Earlier quoted context omitted.
At the expense of increasing the complexity to read code.
How is the complexity increased?
Not necessarily more complex, but not less complex either IMO. I often say complexity can’t be eliminated, only spread around differently; I think we’re seeing that here.
Re: Ruby adds experimental support for Rightward assignments
#14{ "age" => age, "name" => name }
I like the idea a lot. It'd probably allow for some nice functional looking code, but that's also the problem... it'd only look functional. And I think without VM/compiler/runtime support of functional programming it's pretty much a big waste of time.
I can use piece shit for a shoehorn; doesn't mean I should.
Re: Ruby adds experimental support for Rightward assignments
#15Re: Ruby adds experimental support for Rightward assignments
#16"foobar" => upcase() => x
Re: Ruby adds experimental support for Rightward assignments
#17Does sort of make a hash in Ruby more confusing to the untrained eye (unless the hash rocket is totally dead, I haven't written Ruby since like the 2.3 days): { "age" => age, "name" => name } I like the idea a lot. It'd probably allow for some nice functional looking code, but that's also the problem... it'd only look functional. And I think without VM/compiler/runtime support of functional programming it's pretty mu…
Re: Ruby adds experimental support for Rightward assignments
#18To me this seems like a clear loss. The syntax is (as far as I can tell) strictly more verbose than the existing assignment syntax. Ruby is already plagued by a million-and-one ways to do everything, but at least in other cases simplicity (à la zen of Python) trades off for brevity.
Re: Ruby adds experimental support for Rightward assignments
#19Earlier quoted context omitted.
At the expense of increasing the complexity to read code.
How is the complexity increased?
2 ways to do something is more complex than 1.
But it's more than just the syntax of the code. It now means new lint rules, new coding standards in projects (some will allow => assignment, some will encourage conformity to legacy code, and others will disallow it entirely). There will be new Rubocop rules and other editor configs to update for proper syntax highlighting.
Syntactic changes like this with little obvious benefit need to be looked at skeptically. Just because something can be done, doesn't mean it should be.
Re: Ruby adds experimental support for Rightward assignments
#20I get why you'd want it, but I'm not sure they should be reusing => for it, since that already means something in Ruby.
On the other hand Ruby has already such a extensive syntax that it's hard to come up with something else that would not already be taken. -> represents lambda, >> is a valid method name, etc.