Created
January 7, 2014 23:17
-
-
Save anonymous/8308733 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 prompt | |
print '> ' | |
end | |
def counter(maxcount) | |
numbers = [] | |
for i in maxcount | |
puts "At the top of i is #{i}" | |
numbers.push(i) | |
i += 1 | |
puts "Numbers now: #{numbers}" | |
puts "At the bottom of i is #{i}" | |
end | |
end | |
prompt; counter(0..5) | |
# how do i get this to accept user input without throwing errors? | |
# I've tried counter(gets.to_i) but error is thrown in that case: | |
# rub27.rb:6:in `counter': undefined method `each' for 4:Fixnum (NoMethodError) | |
# from rub27.rb:15:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment