Skip to content

Instantly share code, notes, and snippets.

@cnosuke
Created October 23, 2012 10:23
Show Gist options
  • Save cnosuke/3938058 to your computer and use it in GitHub Desktop.
Save cnosuke/3938058 to your computer and use it in GitHub Desktop.
そんなに深い意味は無いけど動的にclass選らんであんなことやこんなこと出来たら便利そうな時あるんじゃねっていうアレ
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