Skip to content

Instantly share code, notes, and snippets.

@borisd
Last active January 3, 2016 05:19
Show Gist options
  • Save borisd/8415129 to your computer and use it in GitHub Desktop.
Save borisd/8415129 to your computer and use it in GitHub Desktop.

Some ruby comments

Spaces

You can't have space betwen function and open bracket

This is wrong: hello (params) (Notice the space !)
This is right: hello(params)
This is right: hello( params )

Special characters

You can use ! and ? in function names:

def home?(person)
   person.location == :home
end
 
home?(moshe)

Call function without brackets

def text(x)
   puts "Hello #{x}"
 end

This is legal: text('boris') This is legal: text 'boris'

So when you see:
validate :something, { rule: 11 }

Its really like:
validate(:somethig, { rule: 11 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment