Skip to content

Instantly share code, notes, and snippets.

@yokolet
Created April 1, 2012 16:50
Show Gist options
  • Select an option

  • Save yokolet/2277004 to your computer and use it in GitHub Desktop.

Select an option

Save yokolet/2277004 to your computer and use it in GitHub Desktop.
Ruby runtimes of singlethreaded ScriptingContainer and irb
irb(main):002:0> require 'java'
=> true
irb(main):003:0> JRuby.runtime
=> #<Java::OrgJruby::Ruby:0x394a8cd1> <--- irb's runtime
irb(main):004:0> c = org.jruby.embed.ScriptingContainer.new(org.jruby.embed.LocalContextScope::SINGLETHREAD)
=> #<Java::OrgJrubyEmbed::ScriptingContainer:0x7664e5b2>
irb(main):005:0> c.getProvider.getRuntime
=> #<Java::OrgJruby::Ruby:0x5f5fc606> <--- ScriptingContainer's runtime
irb(main):006:0> ABC = 10
=> 10
irb(main):007:0> c.run_scriptlet("ABC=100")
=> 100
irb(main):008:0> ABC
=> 10 <--- irb says ABC is 10
irb(main):009:0> c.run_scriptlet("ABC")
=> 100 <--- ScriptingContainer says ABC is 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment