Created
April 24, 2015 11:47
-
-
Save ntijoh-daniel-berg/3bd34bf228d7861ec302 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
def print_names(names:) | |
# i = 1 | |
# while i < names.length | |
# puts names[i].upcase | |
# i += 1 | |
# end | |
# for name in names | |
# puts name.upcase | |
# end | |
names.each do |name| | |
puts name.upcase | |
end | |
end | |
def print_with_position(names:) | |
# i = 0 | |
# while i < names.length | |
# puts "#{i + 1} #{names[i]}" | |
# i += 1 | |
# end | |
# i = 1 | |
# for name in names | |
# puts "#{i} #{name}" | |
# i += 1 | |
# end | |
names.each_with_index do |name, i| | |
puts "#{i + 1} #{name}" | |
end | |
end | |
a = ['bosse', 'edvard', 'daniel'] | |
print_with_position(names: a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment