Unless

hungry = false
if false
puts “I’m writing Ruby programs!”
else
puts “Time to eat!”
end

I can’t figure out wear to put the unless please help.

Hi instead  of if try to put unless
And I think that it should be like that

hungry = false
unless hungry
puts "I'm writing Ruby programs!"
else 
puts "Time to eat!"
end

I don’t know why hungry = false , why isn’t hungry = true , could you tell me what the difference between the two

Hi the unless statement is look like the if and else statement but the only difference between them is that the unless statement work only if the statement is false

@gigamaster93743 the semantics in the statment are actually confusing and should be as follows

tummyfull = false
unless tummyfull
puts “Time to eat!”
else
puts “get back to coding”

#as long as tummyfull = false which means you are not full you will show time to eat and if tummyfull = true the console will show get back to coding.

1 Like