I get a warning with the following code using ruby 1.9.3-p194
if (x = true)
puts 'it worked'
end
# => warning: found = in conditional, should be ==
However, if I assign an array, no warning
if (x = [true])
puts 'it worked'
end
# => 'it worked', then returns nil since return of 'puts' is nil
Why does using a string cause a warning? Or maybe a better question, why is it that using an array does NOT cause a warning?
Ruby reports warning when assigning (Literals: Fixnum, Symbol, String), nil and true/false
ruby-1.9.3-p194
parse.c:15026