Skip to content

Instantly share code, notes, and snippets.

@jgwhite
Last active December 10, 2015 13:58
Show Gist options
  • Select an option

  • Save jgwhite/4444452 to your computer and use it in GitHub Desktop.

Select an option

Save jgwhite/4444452 to your computer and use it in GitHub Desktop.
Why Ruby is Delightful
my_array = %w[a b c d e f] #=> ["a", "b", "c", "d", "e", "f"]
my_array[0..3].map &:upcase #=> ["A", "B", "C", "D"]
my_array[0...3].map &:upcase #=> ["A", "B", "C"]
my_array.first(3).map &:upcase #=> ["A", "B", "C"]
Time.new(2013, 1, 3).thursday? #=> true
(1..10).to_a.group_by &:odd? #=> {true=>[1, 3, 5, 7, 9], false=>[2, 4, 6, 8, 10]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment