Why can't I assign a boolean value to an instance variable

Hello,

I have a line of code in my controller:
@my_var = true # false

However, @my_var is false after the assignment. When I do the same thing with a locally scoped variable it is set to true as expected. Does anyone know why this is?
local = true # true

Thank you!

How did you determine that @my_var is false? Did you try to print it or something? What if you have a spelling mistake? (Note that if you call @misspelledvar in Ruby, it gives you a falsey value (nil) even if it was never assigned.) Could it be that it got re-assigned elsewhere in the code?

Your message is too short and lacking in information to be able to help you. For example, you mention “controller” without telling us what framework you are using. I assume it’s Rails, but could you please confirm?

Also, could you provide a more complete example of the code by including the entire Controller action at least (or the entire Controller if you can share it)?