Ruby if statements is always else

puts "Commands: /startEngine, /upgrade"
command = gets
if command.include? "/"
    command.slice! "/"
    isStartEngine = command <=> "startEngine"
    if isStartEngine == 0
        puts "Starting engine"
        sleep(1)
        print "3"
        sleep(1)
        print "2"
        sleep(1)
        print "1"
        sleep(1)
        print "GO!"
    else
        puts "Unknown"
    end
end

That is my code but it always returns else on if isStartEngine. Using a case doesn't work and I don't know what will and I am new to ruby. Sorry if it is a newbie question. Thank you!



Read more here: https://stackoverflow.com/questions/65043702/ruby-if-statements-is-always-else

Content Attribution

This content was originally published by Annoying_Brother at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: