vendredi 27 novembre 2020

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!

Aucun commentaire:

Enregistrer un commentaire