Skip to content

Instantly share code, notes, and snippets.

@qcam
Last active August 29, 2015 14:00
Show Gist options
  • Save qcam/11478742 to your computer and use it in GitHub Desktop.
Save qcam/11478742 to your computer and use it in GitHub Desktop.
30 Randoms Ruby (Rails) Tips - by Winston TeoFrom https://speakerdeck.com/winston/random-ruby-and-rails-tips

##Ruby (Rails) tips

####1. Array Initialization

if x.is_a?(Array)
  x.each { |x| puts x } 
else
  puts x
end

=>

Array(x).each { |x| puts x }

####2. Underscore as separator

n = 5000000     # => 5000000
m = 5_000_000   # => 5000000
n == m          # => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment