Skip to content

Instantly share code, notes, and snippets.

@pmatsinopoulos
Created March 14, 2015 07:39
Show Gist options
  • Save pmatsinopoulos/0ca696021208de4d5971 to your computer and use it in GitHub Desktop.
Save pmatsinopoulos/0ca696021208de4d5971 to your computer and use it in GitHub Desktop.
A Small Ruby program Teaching correct indentation
def fav_foods
food_array = []
3.times do
puts "Name a favorite food"
food_array << gets.chomp
end
p food_array
puts "Your favorite foods are #{food_array.join(", ")}"
food_array.each do |food| # do something to each element in food_array; that element is to be referred to as food
puts "I like #{food} too!" # the thing we are doing
end # ends the loop
end
fav_foods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment