Skip to content

Instantly share code, notes, and snippets.

@slagyr
Created October 20, 2009 16:07
Show Gist options
  • Save slagyr/214380 to your computer and use it in GitHub Desktop.
Save slagyr/214380 to your computer and use it in GitHub Desktop.
one.rb -------------------------------------
$GLOBAL = "ONE"
class Foo
def global
return "#{__FILE__}:GLOBAL = #{$GLOBAL}"
end
end
foo = Foo.new
puts "foo.global: #{foo.global}"
Java::Main.thing = foo
two.rb --------------------------------------
puts "$GLOBAL: #{$GLOBAL}"
$GLOBAL = "TWO"
thing = Java::Main.thing
puts "thing: #{thing}"
puts "thing.global: #{thing.global}"
output --------------------------------------
foo.global: ruby1:GLOBAL = ONE
$GLOBAL:
thing: #<Foo:0x1b4b74a7>
thing.global: ruby1:GLOBAL = TWO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment