Canonical method to check for jruby

I have:

if RUBY_PLATFORM =~ /java/
#do jruby specific thing here
#do mri specific thing here

in my code in a couple of places, so that it can run on mongrel or
Glassfish. I was wondering if that’s the best way to do it?

-Matt McKnight-
LMN Solutions, Inc.
[email protected]

Hi Matthew,

Yes, this is one of the most wildly used methods, but it has one
drawback – it’s not guaranteed to work forever, since one day the
RUBY_PLATFORM value might change (unlikely, but possible). Not to
mention that any other java-based implementation of Ruby might also
satisfy that check.

The canonical and 100% reliable way to detect JRuby is:
if defined? JRUBY_VERSION


On Thu, Jul 24, 2008 at 7:23 PM, Matthew McKnight
[email protected] wrote:

-Matt McKnight-
LMN Solutions, Inc.
[email protected]

To unsubscribe from this list, please visit: