Created
October 23, 2012 10:23
-
-
Save cnosuke/3938058 to your computer and use it in GitHub Desktop.
そんなに深い意味は無いけど動的にclass選らんであんなことやこんなこと出来たら便利そうな時あるんじゃねっていうアレ
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
class Human | |
end | |
class Male < Human | |
def self.who | |
'I am male.' | |
end | |
def self.sex?(s) | |
s == 'm' | |
end | |
end | |
class Female < Human | |
def self.who | |
'I am female.' | |
end | |
def self.sex?(s) | |
s == 'f' | |
end | |
end | |
p [Male, Female].find{ |h| h.sex?('m')}.who |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment