Created
November 18, 2008 06:27
-
-
Save jballanc/26070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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