From: Robert Klemme Date: 2013-01-21T02:55:18+09:00 Subject: Re: 2Q: Getting first 4 elements from array and calling class methods directly On Sun, Jan 20, 2013 at 3:26 PM, Sandor Szücs wrote: > On 1/20/13 3:08 PM, Panagiotis Atmatzidis wrote: > >> 1) Is there any more elegant[1] way to get the first for elements of '@entries' object array? > > irb:0> a = (1..10).to_a > => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > irb:0> a.take(3) > => [1, 2, 3] > irb:0> a > => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > irb:0> a.pop(3) > => [8, 9, 10] > irb:0> a > => [1, 2, 3, 4, 5, 6, 7] > irb:0> a.shift(3) > => [1, 2, 3] > irb:0> a > => [4, 5, 6, 7] And then there is irb(main):001:0> a = (1..10).to_a => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] irb(main):002:0> a.first(3) => [1, 2, 3] Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/