From: Nuralanur@... Date: 2006-07-23T01:21:44+09:00 Subject: Re: Showing part of an array.... -------------------------------1153585298 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Rosina, I'll explain this line: colors[0..2].collect{ |color| color.name }.join(', ') for an Array colors , say colors=['red','green','yellow'], you can choose the first three entries by colors[0..2], then you map the elements of this Array (i.e., the Strings using the collect command. To be able to deal with them, you give the iterator a name, say |color|. But that's for the individual entries - you're trying to puit together a String consisting of all the elements of color[0..2] ... color.name only makes sense if you had defined it as a function. Then you can map the entire Array to another Array and show only the first so-and-so many of them. The following code translates some color names into French. (I am not using the most compact syntax Ruby is capable of below, since I want to keep things easily understandable): class String def name if self=='red' return 'rouge' end if self=='blue' return 'bleu' end if self=='green' return 'vert' end if self=='white' return 'blanc' end if self=='yellow' return 'jaune' end return 'unknown color' # Computer doesn't know so much French end end Best regards, Axel -------------------------------1153585298--