From: "Mauricio Fernández" Date: 2003-01-23T02:13:42+09:00 Subject: Re: extend (Re: a single class that supports multiple facets/interfaces) On Thu, Jan 23, 2003 at 02:07:14AM +0900, Gavin Sinclair wrote: > Well, here's some cool code then: > > >> module M; def hi; "hi"; end; end > => nil > > >> class A; end > => nil > > >> A.include M > NameError: private method `include' called for A:Class > from (irb):3 > > >> class Module > >> def inc(*args) > >> include *args > >> end > >> end > => nil > > >> A.inc M > => A > > >> A.new.hi > => "hi" > > Gavin (who's trying to get his Ruby-English ratio up...) Me too :) batsman@tux-chan:/tmp$ irb --prompt-mode simple >> Module.instance_eval < Module >> module M; def hi; "hi"; end; end => nil >> class A; end => nil >> A.new.hi NameError: undefined method `hi' for # from (irb):6 >> A.include M => A >> A.new.hi => "hi" -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Never make any mistaeks. -- Anonymous, in a mail discussion about to a kernel bug report