Re:Using the switch(true) pattern in JavaScript
by cryptonector on Monday April 12, 2021 @03:04PM
(#26783654)
On the contrary, if early returns allow you to outdent a larger portion of code then it's quite a readability win. As long as all the early return cases are bite-sized and the last case long-ish, it's a readbility win.
[ Parent
| on HN ]
Re:Using the switch(true) pattern in JavaScript
by jbverschoor on Monday April 12, 2021 @03:08PM
(#26783719)
And certain languages allow:
return nil if n.nil?
Re:Using the switch(true) pattern in JavaScript
by sneak on Monday April 12, 2021 @07:14PM
(#26786323)
I really miss postfix conditionals from perl/ruby/coffeescript in all of the other languages. (Along with until/unless, which are just while! and if!.)
I asked on the go-nuts mailing list about perhaps including them in go2, but it seems many of the people who replied hate them.