“Robert Klemme” email@example.com wrote in message news:c0q8nb$19imk0$1@ID-52924.news.uni-berlin.de…
“Daniel Berger” firstname.lastname@example.org schrieb im Newsbeitrag
email@example.com (Yukihiro Matsumoto) wrote in message
Since I haven’t seen a full discussion on the topic, I thought I
see what Ruby programmers think of “traits” as an OO concept. Cool
idea? Or a solution in need of a problem?
“module” in Ruby and “trait” are very similar idea.
Yes, I thought so, too. Their argument against mixins boiled down to
"What if you have identical methods in two different modules that you
wish to ‘include’?". But, so far that just hasn’t happened in my
The problem that I see is with using Modules is when traits have to be
exchanged during the life time of an instance. At least I didn’t manage
to include a Module and de-include if afterwards.
It has been brought up a few times here in the past:
Sometimes you want an object’s role to change so it would be nice if
there were some sort of uninclude or unextend
In the meantime, it probably wouldn’t be too hard to 'roll your own’
uninclude. Just get the list of instance methods from the module and
undef_method in the class. Something like:
…I’m still figuring out how to do unextend (which is arguably more
useful than uninclude).
In message “OT: Traits” > > > on 04/02/14, Daniel Berger firstname.lastname@example.org writes: