From: Bill Kelly Date: 2002-12-06T07:06:31+09:00 Subject: Re: elseif? Hi, From: "Ted" > > But we already have aliases all over the place in the classes > > and libraries. Look at just the Array class: > > > > collect! map! > > size length > > indices indexes > > slice [ ] > > to_ary to_a > > > Yuk! Ruby was presented to me as a 'clean' language. > Aliases are -- in my not-so-humble-opinion -- an abomination. > Aliases mean that when reading someone else's code you have to remember TWO things instead of one. > They serve no purpose except the preservation of the status quo of a cat-heard of programmers. I used to think these kinds of aliases were kind of quirky when I first read through Pickaxe learning Ruby... However, in some code I wrote last night, I used collect and map one right after another. Because the particular naming in this context seemed more appropriately analogous to what the code was doing... The lines are: image_filenames.map! {|fname| File.basename(fname, ".jpg") } bead_shots = image_filenames.collect {|fname| BeadShot.new(fname) } ...See? 'Cause I wanted to "map" the filenames to some alternate arrangement; but I wanted to "collect" BeadShot objects from the filenames! :-) I thought it was pretty cool that Ruby allowed me to specify my intent in a way that seemed so natural to me... I could envision using :size vs. :length similarly... (to_ary and to_a? well.... dunno about that :) Just my thoughts . . . Regards, Bill