5 ms·
What's with the use of curly brackets for multi-line blocks?
by carbon8 15y ago
What's with the use of curly brackets for multi-line blocks?
- joshbuddy 15y agoUm, where did you see those? I think I used curly braces for a lot of the Renee { .. } examples, and use the do..end once I'm inside there. That's just my style, but, you can use which ever one you prefer (and of course, if the precedence is correct.)
- rue 15y agoMost “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.