3 ms·
The waterfall of end statements in Ruby reminds me of pascal. Seems verbose.
by andrewstuart 2y ago
The waterfall of end statements in Ruby reminds me of pascal. Seems verbose.
- pansa2 2y agoNobody ever likes my suggestion to write them all on one line. I thought it was neat - the length of the word `end` makes it line up perfectly with 4-space indentation: class HtmlTransform class Code < Base def markdown "`#{node.text}`" end end end
- Etheryte 2y agoI think it's pretty easy to see why people would dislike it, with each on their own line and indented, it's very easy to track what ends where. With this version, not so much, if you're e.g. five nests deep and then see three end statements on one line.
- pansa2 2y agoI think this is fine - I don't see why having the `end`s on separate lines would make it easier to understand: if ... if ... if ... if ... if ... x = 1 end end end y = 2 end end
- Borg3 2y agoWhen I see such code I chukle... Really? I always try to make my code as flat as possible, either using next or break (or split to function and use return). Thats why I sometimes miss goto. But case can emulate it pretty fine.
- rco8786 2y agoInteresting. I consider myself a rubyist and never considered this. Perhaps because the rest of the language is so concise that this little verbosity never really bothered me