L
Live365 Live365
Hi,
I am new to ruby. I am trying to get input from the user and then trying
to compare that string to perform action depending on the comparision
result:
Here is the code
while command = STDIN.gets
command.chomp
print #{command}
if command == "add"
addnums(num1,num2)
break
else
print"not correct command"
end
end
When I run this code and enter add it is giving output : Not the right
command.
Was expecting method addnums be called. because command is add which is
a string and if statement to evaluate to be true.
I am new to ruby. I am trying to get input from the user and then trying
to compare that string to perform action depending on the comparision
result:
Here is the code
while command = STDIN.gets
command.chomp
print #{command}
if command == "add"
addnums(num1,num2)
break
else
print"not correct command"
end
end
When I run this code and enter add it is giving output : Not the right
command.
Was expecting method addnums be called. because command is add which is
a string and if statement to evaluate to be true.