Skip to content

Instantly share code, notes, and snippets.

@ntijoh-daniel-berg
Created April 24, 2015 11:47
Show Gist options
  • Save ntijoh-daniel-berg/3bd34bf228d7861ec302 to your computer and use it in GitHub Desktop.
Save ntijoh-daniel-berg/3bd34bf228d7861ec302 to your computer and use it in GitHub Desktop.
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