Skip to content

Instantly share code, notes, and snippets.

@chad
Created January 19, 2011 18:23
Show Gist options
  • Save chad/786588 to your computer and use it in GitHub Desktop.
Save chad/786588 to your computer and use it in GitHub Desktop.
# use .each (or each_with_index) and iteration to implement these
array_of_numbers = [1,2,3,4,5]
number_to_add = 2
puts array_of_numbers.add_a_number_to_each_of_these_numbers(number_to_add)
# => [3, 4, 5, 6, 7]
list = [:name, 'Chad', :place, 'Virginia']
list.turn_into_hash
# {:name => 'Chad', :place => 'Virginia'}
array_of_numbers.sum_these_numbers
# => 15
array_of_numbers.get_numbers_less_than(4)
# => [1,2,3]
array_of_numbers.get_numbers_greater_than(1)
# => [2,3,4,5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment