From: "Mauricio Fernández" Date: 2003-02-01T22:12:46+09:00 Subject: Re: 2 classes, same name On Sat, Feb 01, 2003 at 09:39:26PM +0900, Tom Sawyer wrote: > did you know Ruby can have mutiple classes defined with the exact same > constant, yet they be different classes? > > module X1 > end > > module X2 > end > > class XX > def XX.record(*mods) > x = XX.clone > x.class_eval { include *mods } > return x > end > def initialize > puts self.class.included_modules > puts self.class puts self.class.id > puts > end > end > > xx = XX.record(X1, X2).new > yy = XX.record(X1).new puts "XX: #{XX.id}" Errr, no? batsman@tux-chan:/tmp$ ruby e.rb X2 X1 Kernel XX 538072192 X1 Kernel XX 538071272 XX: 538072512 -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com damn my office is cold. need a hot secretary to warm it up. -- Seen on #Linux