3 ms·
Most “rules” about {…} vs. do…end are nonsense. I tend to use {…} unless I can't be bothered to put parens around the arguments.
by rue 15y ago
Most “rules” about {…} vs. do…end are nonsense. I tend to use {…} unless I can't be bothered to put parens around the arguments.
- ryeguy 15y agoThey're nonsense in that they are without ryhme or reason, but you should be following the community standard (curlies for one liners, do/end for everything else). I'd honestly pass on an open source project not following the generally agreed upon ruby standard.
- seanp2k2 15y ago>"They're nonsense in that they are without ryhme or reason, but you should be following the community standard (curlies for one liners, do/end for everything else)." That's my reasoning too. At first, I thought it was more readable (read: familiar) to use curly braces, but now I stick with do...end for blocks >1 line. Sometimes it's helpful for breaking up complex nested map() blocks as well.
- rue 15y ago…Except that that isn't “the community standard”. It's one of the more popular varieties, of about equal support with {…} for when you use the return value.