On Sun, Jan 20, 2013 at 3:26 PM, Sandor Szücs <[email protected]> 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/ -- [email protected] | https://groups.google.com/d/forum/ruby-talk-google?hl=en
