J
Jim Crossley
This surprised me:
module English; def say; "yes"; end; end
module French; def say; "oui"; end; end
x = Object.new
x.extend English
x.say # "yes"
x.extend French
x.say # "oui"
x.extend English
x.say # "oui"
What wrong assumptions am I making that this surprises me? What is
the more elegant "Ruby way" of alternating an object's behavior at
runtime?
Thanks,
Jim
module English; def say; "yes"; end; end
module French; def say; "oui"; end; end
x = Object.new
x.extend English
x.say # "yes"
x.extend French
x.say # "oui"
x.extend English
x.say # "oui"
What wrong assumptions am I making that this surprises me? What is
the more elegant "Ruby way" of alternating an object's behavior at
runtime?
Thanks,
Jim