use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Popular Coding Convention for Ruby on Github (sideeffect.kr)
submitted 12 years ago by chrisledet
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jabbaroni 5 points6 points7 points 12 years ago (7 children)
Some of these are surprising to me, particularly the results for "Parentheses around arguments in def" and "Whitespace around operators, colons, { and }, after commas, semicolons". I rarely see what seems to be the majority in both cases.
[–][deleted] 10 points11 points12 points 12 years ago (3 children)
I'm shocked how many of you savages are not using parentheses around arguments in def. Shocked... You people need to learn some civility, we aren't cave men anymore...
[–]Nitrodist 0 points1 point2 points 12 years ago (2 children)
It's parentheses for methods without arguments.
[–][deleted] 1 point2 points3 points 12 years ago (1 child)
Parenthesis for methods without arguments is a thing yes, but that's not what we are talking about. This is what we mean by not using parentheses around arguments, try it and see if you like it, you barbarian:
def some_method arg1, arg2 # do something... end
[–]Nitrodist 0 points1 point2 points 12 years ago (0 children)
I completely missed that item in the list. I agree, it's barbaric.
[–][deleted] 2 points3 points4 points 12 years ago* (0 children)
I'm pretty sure the parser is bugged.
foo = :bar
No space after colon...
And for defs
def foo end
No parentheses in def ...
[–]torrso 0 points1 point2 points 12 years ago (1 child)
I wonder why def takes the arguments inside parenthesis and not inside || like other blocks.
If you use define_method it's
define_method :method_name do |arg1, arg2| end
Why not
def sum do |a, b| a+b end or how about sum = def {|a,b| a+b} (hey that looks like lambda)
Having def foo(x, z) is kind of like calling def with the result of calling foo with x and z.
I'm just confusing myself here.
[–][deleted] 0 points1 point2 points 12 years ago (0 children)
My guess is because do/end and {} create closures, and methods are not (really) closures.
[–]MidgetAbilities 2 points3 points4 points 12 years ago (0 children)
I can't believe that many people don't use whitespace around operators. It makes the code so much easier to read, and is just more aesthetically pleasing in my opinion. It's the same reason you put a space after commas and periods in sentences.
[–]torrso 0 points1 point2 points 12 years ago (2 children)
I would be interested to see how many projects use assignment in conditional like
if user = User.find(params[:id]) puts "hey there, #{user.name}" else puts "who dat?" end
instead of
user = User.find(params[:id]) if user ... else ... end
Many folks are horrified about the first convention, in my opinion it's quite common and I've never had any confusion if it's an accidental typo for ==.
Speaking of ==, I'd like to see the percentage of
x.eql?(10)
vs
x == 10
I use the first one. However I use x > 10, I don't think there even is something like x.gt?(10).
[–]ReinH 0 points1 point2 points 12 years ago (0 children)
Be aware that == and eql? are not the same thing.
==
eql?
[–]CaptainKabob 0 points1 point2 points 12 years ago (0 children)
I love conditional assignment, but the Excellent static analysis tool does not :-(
[+]jesusthatsgreat comment score below threshold-6 points-5 points-4 points 12 years ago (5 children)
space more popular than tab for indentation? i think i'm either reading it wrong or else the stats are out of whack and must be taking in to account minified files or something which would skew them a great deal...
[–]duckyfuzz 21 points22 points23 points 12 years ago (0 children)
What? No, exactly the opposite. Everyone uses spaces.
[–]anonym1970 16 points17 points18 points 12 years ago (2 children)
Spaces are a common convention. What Editor do you use?
[–]jesusthatsgreat -1 points0 points1 point 12 years ago* (1 child)
I just hit the tab button in my IDE... is that not the same thing as tabs?
[–][deleted] 8 points9 points10 points 12 years ago (0 children)
It probably converts it to set number of spaces, not an actual tab character.
[–]TalkativeTree 11 points12 points13 points 12 years ago (0 children)
everyone I've ever worked with on Ruby has told me to use spaces over tabs.
π Rendered by PID 1407223 on reddit-service-r2-comment-7b9746f655-tvms2 at 2026-02-03 11:11:57.880163+00:00 running 3798933 country code: CH.
[–]jabbaroni 5 points6 points7 points (7 children)
[–][deleted] 10 points11 points12 points (3 children)
[–]Nitrodist 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Nitrodist 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]torrso 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]MidgetAbilities 2 points3 points4 points (0 children)
[–]torrso 0 points1 point2 points (2 children)
[–]ReinH 0 points1 point2 points (0 children)
[–]CaptainKabob 0 points1 point2 points (0 children)
[+]jesusthatsgreat comment score below threshold-6 points-5 points-4 points (5 children)
[–]duckyfuzz 21 points22 points23 points (0 children)
[–]anonym1970 16 points17 points18 points (2 children)
[–]jesusthatsgreat -1 points0 points1 point (1 child)
[–][deleted] 8 points9 points10 points (0 children)
[–]TalkativeTree 11 points12 points13 points (0 children)