Created
September 2, 2011 11:21
-
-
Save IndianGuru/1188404 to your computer and use it in GitHub Desktop.
JRuby programs
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
# 1 | |
class Rubyist | |
def self.who | |
"Geek" | |
end | |
end | |
puts Rubyist.who | |
# 2 | |
class Rubyist | |
class << self | |
def who | |
"Geek" | |
end | |
end | |
end | |
puts Rubyist.who | |
# 3 | |
class Rubyist | |
end | |
def Rubyist.who | |
"Geek" | |
end | |
puts Rubyist.who | |
#4 | |
class Rubyist | |
end | |
Rubyist.instance_eval do | |
def who | |
"Geek" | |
end | |
end | |
puts Rubyist.who | |
# 5 | |
class << Rubyist | |
def who | |
"Geek" | |
end | |
end | |
puts Rubyist.who |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment