A
alex.m.mcpherson
Hi there, this is my first program in any programming language, and
I'm not quite sure how to help myself learn yet, so here is my mal-
formed code:
sum = 0
print "Type the number to add up until: "
gets
chomp
for value in 1..#{$_}
sum = sum + value
end
puts sum
The error says that Ruby needs to chomp a string, but in just the
previous example in the book, chomp was used on a number. What
(presumably) simple fix will take care of this?
I'm not quite sure how to help myself learn yet, so here is my mal-
formed code:
sum = 0
print "Type the number to add up until: "
gets
chomp
for value in 1..#{$_}
sum = sum + value
end
puts sum
The error says that Ruby needs to chomp a string, but in just the
previous example in the book, chomp was used on a number. What
(presumably) simple fix will take care of this?