From: Matthew Kerwin Date: 2013-04-24T13:42:26+09:00 Subject: Re: what is the $- magic global? Julio Olivera wrote in post #1106717: > If you try it on http://repl.it/, $- immediately returns nil. Perhaps on > irb the interpreter is waiting for more input? I can't test it right > now, > but what happens if you write something like the following? > >> $-x = 42 >> $- >> x > > Julio > @_joliv > I think that's the right track. There's something a little bit magic going on in IRB, because the second line is treated as a whole new line, thus: irb(main):001:0> $-x = 42 => 42 irb(main):002:0> $- irb(main):003:0> x NameError: undefined local variable or method `x' for main:Object from (irb):3 from /usr/local/bin/irb21:12:in `
' irb(main):004:0> $- irb(main):005:0> 1 => 1 Whatever it is, I guess the upshot is "don't use $- at the end of a line in IRB". -- Posted via http://www.ruby-forum.com/.