Skip to content

Instantly share code, notes, and snippets.

@jballanc
Created November 18, 2008 06:27
Show Gist options
  • Save jballanc/26070 to your computer and use it in GitHub Desktop.
Save jballanc/26070 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
module Example
def self.hello(arg)
puts "Hello, #{arg}! You are Object \#: #{arg.object_id}"
arg = 'different'
puts "Arg is now #{arg}; Object \#: #{arg.object_id}"
end
def self.not_local_hello
puts "Hello, #{@arg}! You are Object \#: #{@arg.object_id}"
@arg = 'different'
puts "Arg is now #{@arg}; Object \#: #{@arg.object_id}"
end
def local_hello
puts "Hello, #{@arg}! You are Object \#: #{@arg.object_id}"
@arg = 'different'
puts "Arg is now #{@arg}; Object \#: #{@arg.object_id}"
end
end
@arg = "Joe"
puts "Joe is #{@arg}; Object \#: #{@arg.object_id}"
Example.hello(@arg)
puts "Joe is still #{@arg}; Object \#: #{@arg.object_id}"
Example.not_local_hello
include Example
local_hello
puts "Now Joe has become #{@arg}; Object \#: #{@arg.object_id}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment