lundi 30 novembre 2015

Using variables for if statement conditional in ruby

I am trying to use variables in if statement conditionals in Ruby and I am not getting the behavior I would expect.

I think the issue is with the "and" portion of the statement.

a = 1
b = 4
c = 3

@test = (a<b) and (b<c)

x = if @test
    puts "yes"
else
    puts "no"
end

That is returning "yes" when it should be returning "no", like it only evaluates the (a

Aucun commentaire:

Enregistrer un commentaire