Hi,
In message "Re: Surprising behavior when extending instances"
on Sat, 14 Nov 2009 23:50:05 +0900, Jim Crossley <jim / crossleys.org> writes:
|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?
#extend (and #include) include a module only once.
matz.