hi I'm new to ruby and im trying to write some simple codes but i cant
get the 'if's to work. below what i mean. how can i fix the ruby code
for the ifs to work?
no matter what i write it always returns "invalid input"
##################Code#########################
while counter < 1 do
print ("put 10, 20 or 30 ")
input = gets()
if input == '10'
person1 += 1
counter += 1
elsif input == 20
person2 += 1
counter += 1
elsif input == 30
person3 += 1
counter += 1
else
puts("Invalid input")
end
end
···
##############################################
if i were to write it in python i would do it somewhat like this:
##################Code#########################
while counter < 5 :
vector.append(input('put 10, 20 or 30 '))
if vector [counter] == '10' :
p1 += 1
counter += 1
elif vector [counter] == '20':
p2 += 1
counter +=1
elif vector [counter] == '30':
p3 += 1
counter += 1
else:
print ("invalid input")
##############################################
last question whats the difference between ruby and ruby on rails?
--
Posted via http://www.ruby-forum.com/.