Created
January 19, 2011 18:23
-
-
Save chad/786588 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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