How would i get this to work


Hw can I get this to work correctly?

error: undefined method `problem' for #
How do i get this to work correctly...

my code:

problem = 8 > 9
print "i dont get it" unless problem print "or do i?..."

(its just printing or do i then error message)


Compare your code to the example in the instructions


Hey ionatan

I know my code is not the same as that of the course, i did what the instructions asked me and am now near finishing the course I was just curious at the time, as how id make something like this work....

I thought if it was true then it'd print "i don't get it" but when i changed it to be true - i put 10>9 it still printed the false message. Could i make it work with unless? like out of curiosity what would i put?


Your code is equivalent to:

problem = 8 > 9
print "i dont get it" unless problem(print("or do i?..."))

And you'll have an error message telling you that you can't use problem as a method because you have defined no such method.

Your code is crashing, one would want to fix that before discussing its other behaviour.

There is also only one branch, it either executes or it doesn't (depending on the condition). There is no else here. There's only "do this if/unless this condition is met"


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.