From: "trans. (T. Onoma)" Date: 2004-09-29T07:13:03+09:00 Subject: Re: Best name for "this method" ? On Tuesday 28 September 2004 05:27 pm, David A. Black wrote: > Hi -- > > On Wed, 29 Sep 2004, trans. (T. Onoma) wrote: > > On Tuesday 28 September 2004 05:44 am, Gavin Sinclair wrote: > > >   foo.methods[:new, :protected]   # if you need combination > > > > This line's got me thinking... How does one define a class [] > > constructor? For example Hash can be use like this: > > > > Hash[:a=>1,:b=>2 ] > > class C > def C.[](...) > ... > end > end Duh! Thanks, I don't know why I thought there was something special about it. > > And then I start to wonder why we can't just use the class name like a > > method? > > > > Hash(:a=>1, :b=>2) > > You can define such methods; for example, there's Integer. A number > of people (including me :-) aren't big fans of method names that begin > with uppercase letters, but it can be done. Right. Well then, I must propose that all such class names be constructor methods too. No sense in confusing things otherwise. By default: def AClass(*args, &blk) AClass.new(*args, &blk) end But for something like Hash, it would be defined like Hash[]. MHO, T. P.S. Okay, this is where you tell me why this is a bad idea ;)