←back to thread

317 points est | 2 comments | | HN request time: 1.114s | source
Show context
korijn ◴[] No.17449188[source]
It feels like we are repeating a mistake the PHP community made years ago. PHP supports assignment in expressions, and the community seems to avoid its use. There are plenty of examples of stackoverflow questions and answers where the problem is caused by coders overlooking an assignment in an expression. You just don't expect assignment to occur in an expression, and its visually similar enough to gloss over it.
replies(4): >>17449245 #>>17449289 #>>17449406 #>>17450205 #
1. werdnapk ◴[] No.17450205[source]
In Ruby, this idiom is fairly common as far as I can tell. Perhaps rubocop (code analyzer) warns against it's usage, but I'm not sure.
replies(1): >>17451780 #
2. korijn ◴[] No.17451780[source]
There's this: https://github.com/rubocop-hq/ruby-style-guide/pull/65