Created
January 7, 2016 10:34
-
-
Save krokrob/b759edddb63592721d0a to your computer and use it in GitHub Desktop.
This file contains 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
array = ['Michel Polnareff', 'Michel Jonasz', 'Michel Delpech', 'Maxime Leforestier'] | |
# "Mr" | |
new_array = [] | |
array.each do |singer| | |
new_array << "Mr #{singer}" | |
end | |
# p new_array | |
# MAP | |
# input : array | |
# output : array with same size | |
new_array = array.map do |singer| | |
"Mr #{singer}" | |
end | |
# p new_array | |
new_array.each do |singer| | |
puts "#{new_array.index(singer) + 1}. #{singer}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment