Ruby adds experimental support for rightward assignments
blog.saeloun.com
Ruby adds experimental support for rightward assignments
1–10 of 172 posts
Re: Ruby adds experimental support for rightward assignments
#2Re: Ruby adds experimental support for rightward assignments
#3Re: Ruby adds experimental support for rightward assignments
#4Re: Ruby adds experimental support for rightward assignments
#5[question]: Is the main benefit of "Rightward assignments" readability and does this provide more benefits?
user.delete() if deleteUser
It is probably thought that this feature would result in similar readability improvements.Re: Ruby adds experimental support for rightward assignments
#6This hurts readability of code with lengthy expressions. Knowing the target of the assignment is usually more important than the particulars of the expression when you're skimming unfamiliar code. Having the variable pushed out to random locations on a ragged right side isn't helpful.
Re: Ruby adds experimental support for rightward assignments
#7Is this true (the 'unnatural' part)? Reading left to right, `age = 42` can be read as "age is 42" which feels perfectly natural in English. `42 => age` would be read as "assign 42 to age"? This feels more awkward to me. I'm not sure I understand why anyone would want Rightward assignment.
Re: Ruby adds experimental support for rightward assignments
#8This hurts readability of code with lengthy expressions. Knowing the target of the assignment is usually more important than the particulars of the expression when you're skimming unfamiliar code. Having the variable pushed out to random locations on a ragged right side isn't helpful.
Unless is great if it's the first or second clause on the line. If it's the tenth, then it feels more like slapstick and I am the butt of the joke. Haha, just kidding, we aren't really going to call that function.
Similarly, rightward:
someBigFunction(thatNeedsAnswersFrom(), otherFunctions(), true) => variableIAmDebugging
Three unnamed Laws of Computing that everyone ignores and at their peril:- Nobody reads your unit tests in a PR
- People glaze over at the end of long lines of code
- Merges are hard
#2 and #3 combine to cause over half of the bad merges I have had to diagnose. Don't save the important bits for the end of a line. If I were still writing Ruby code, I'd be prepping to see more of them.
Re: Ruby adds experimental support for rightward assignments
#9Re: Ruby adds experimental support for rightward assignments
#10[question]: Is the main benefit of "Rightward assignments" readability and does this provide more benefits?