From: Frederick Cheung Date: 2008-07-16T00:50:05+09:00 Subject: Re: Array.drop doesn't work On 15 Jul 2008, at 16:46, Li Chen wrote: > Hi all, > > I try to use #drop to remove several elements from an array but it > doesn't work. > I check "ri Array.drop" and get no info about #drop. But I see this > info > described in http://www.ruby-doc.org/core/classes/Array.html#M000343 > > > ary.drop(n) => array > > Drops first n elements from ary, and returns rest elements in an > array. > > a = [1, 2, 3, 4, 5, 0] > a.drop(3) # => [4, 5, 0] > > > Seems like this was added in 1.8.7 (if you look at the docs for 1.8.6 you'll see it's not there) Fred > I wonder what is going on. > > Thank you very much, > > Li > ######### > C:\Documents and Settings\chen73>irb > irb(main):001:0> a=[1,2,3,4] > => [1, 2, 3, 4] > irb(main):002:0> a.class > => Array > irb(main):003:0> a.drop(1) > NoMethodError: undefined method `drop' for [1, 2, 3, 4]:Array > from (irb):3 > irb(main):004:0> a.drop(2) > NoMethodError: undefined method `drop' for [1, 2, 3, 4]:Array > from (irb):4 > irb(main):005:0> > > ######### > C:\Documents and Settings\chen73>ri Array.drop > Nothing known about Array.drop > -- > Posted via http://www.ruby-forum.com/. >