In this example
def foo(x) if(x > 5) bar = 100 end puts bar end
Then foo (6) Outputs: 100 and foo (3) does not output anything.
However, if I changed the definition to
def foo(x) if(x > 5) bar = 100 end puts bob end
I get the error "undefined local variable or method".
So my question is why am I not getting this error when I call foo (3) and the bar is never set?
ruby
rebo Nov 11 2018-10-11 13:26
source share