June 24, 2008

Slight difference on defined? results

Some piece of ruby logic was depending on a defined? check to identify local-variables. It was working fine in C-Ruby but it failed when ported to JRuby.
So what we found out was that the defined? keywork/method/check/thingy in JRuby gives a slightly different response.
Try it out. In your terminal bring up irb and type:


Then try it with Jruby:


JRuby spits out a local-variable(in-block) whilst C-ruby gives back local-variable only. I suppose this is intentional, although I didn't go down the rabbit hole to confirm it. If you know the rationale I'd like to know it too. Anyways, just a heads up that they are different.

No comments:

Post a Comment