Rails 5.2 project; In a controller I have:
def show
binding.pry
@correct_user = false
some_method or (@correct_user=correct_user) or return
# -> here the value of @correct_user is false
# some other code here
end
some_method
evaluates to false; correct_user
method evaluates to true here; return
is not reached
but right after that @correct_user
var value is false
why is this;
I made another test in 'rails console':
irb(main):001:0> def f
irb(main):002:1> return false
irb(main):003:1> end
=> :f
irb(main):004:0> def a
irb(main):005:1> return true
irb(main):006:1> end
=> :a
irb(main):007:0> @t=false
=> false
irb(main):008:0> f or (@t=a) or return
=> true
irb(main):009:0> @t
=> true
So this works as would expect