From: Andrea Forlin Date: 2007-08-18T20:35:11+09:00 Subject: Re: R: How do you print the first 5 records in an array? ------=_Part_89067_8678474.1187436909208 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline if you need only to puts on screen you can use the solution of stefano, but it's usefull?? Maybe you need to search, operate on the range item, i think. Bye 2007/8/18, Eric : > > Op za 18 aug 12:03:56 2007 CEST schreef Andrea Forlin in > de nieuwsgroep 'comp.lang.ruby': > > > > > @people[0..4].each { |item| puts item } > > > > -----Messaggio originale----- > > Da: list-bounce@example.com [mailto:list-bounce@example.com] Per conto > di > > Bob Sanders > > Inviato: sabato 18 agosto 2007 11.55 > > A: ruby-talk ML > > Oggetto: How do you print the first 5 records in an array? > > > > Let's say I have an array defined as: > > > > @people = ["Jim", "Jen", "Jess", "Jay", "Jack", "John", "Jeff", "Jed", > > "Jill"] > > > > How would I then print out the first 5 records of that array? (i.e. from > > Jim to Jack) > > > > Any ideas? > > I'd do it like this: > > puts @people[0..4] > Jim > Jen > Jess > Jay > Jack > => nil > > Is the .each construct better? > -- > Groeten, > Eric > > ------=_Part_89067_8678474.1187436909208--