Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
"Or equals" operator fails with class variables #3138
The "or equals" operator
[jared:~/projects/mruby] mirb mirb - Embeddable Interactive Ruby Shell > class Test * @@var ||= 'testing' * end (mirb):4: uninitialized class variable @@var in Test (NameError) > class Test2 * @var ||= 'testing' * end => "testing"
Thanks for taking the time! It's easy enough to work around, but I'm trying to run ruby/spec code with as few alterations as possible, so this is very much appreciated!
While the simple case works, in practice I'm seeing "NameError: uninitialized class variable NameError in SocketSpecs." Of course I can't reproduce outside of ruby/spec... but I'll get back to you if I can come up with something.