Skip to content

Instantly share code, notes, and snippets.

@danman01
Created August 7, 2017 03:51
Show Gist options
  • Save danman01/ba59c826fd54b3084102939497138a66 to your computer and use it in GitHub Desktop.
Save danman01/ba59c826fd54b3084102939497138a66 to your computer and use it in GitHub Desktop.
1.upto(10) do |i|
puts "i"
return 'hey I\'m returning!'
end
# what is returned? Why?
def count(upto)
msg = 'hey I\'m returning!'
1.upto(upto) do |i|
puts 'i'
return msg
end
end
# what is returned? Why?
# how do you use the method?
# how can we rewrite the method to go through the entire iteration, and then return the message
# how do we get i to be the current iteration?
def count2(upto)
1.upto(upto) do |i|
puts 'i is ' + i.to_s
end
'hey I\'m returning'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment