Skip to content

Conversation

noahpatterson
Copy link

Thanks!

puts "Ingredients: #{ingredients.split(",")}"
puts "Steps:"
step_num = 1
steps.split(".").each do |step|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruby provides a "each_with_index" that is handy here.

steps.split(".").each_with_index do |step, step_num|
  puts "#{step_num+1}: #{step}\n"
end

It's +1 because indexes are 0 based, but most human stuff is 1 based.

@jwo
Copy link
Member

jwo commented Jan 2, 2014

Cooool!

@jwo
Copy link
Member

jwo commented Jan 2, 2014

Updated to_s looks great 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants