Skip to content

Instantly share code, notes, and snippets.

@tsevdos
Created September 13, 2015 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsevdos/fa82d7afa1960a0b2f6c to your computer and use it in GitHub Desktop.
Save tsevdos/fa82d7afa1960a0b2f6c to your computer and use it in GitHub Desktop.
Ruby tips : Ranges
(1..10) === 4 # => true
(1...10) === 10 # => false
(1..10).to_a # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
(1..10).each_entry {|val| puts "#{val}"}
(1..10).each_with_index {|val, i| puts "#{i} : #{val}"}
1..10 # => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1...10 # => 1, 2, 3, 4, 5, 6, 7, 8, 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment