S
Simon Harrison
Can anyone help with this? I thought grep would find any element that
matches in an array. It seems not...
irb(main):028:0> test = [['one', 'vol1'], ['one', 'vol2'], ['two',
'vol3']]
=> [["one", "vol1"], ["one", "vol2"], ["two", "vol3"]]
irb(main):029:0> test.grep(/one/)
=> []
irb(main):030:0> test.each.grep(/one/)
=> []
irb(main):031:0> test
=> [["one", "vol1"], ["one", "vol2"], ["two", "vol3"]]
irb(main):032:0> test.grep('one')
=> []
irb(main):033:0> test2 = ['one', 'one', 'two', 'three']
=> ["one", "one", "two", "three"]
irb(main):034:0> test2.grep(/one/)
=> ["one", "one"]
irb(main):035:0>
matches in an array. It seems not...
irb(main):028:0> test = [['one', 'vol1'], ['one', 'vol2'], ['two',
'vol3']]
=> [["one", "vol1"], ["one", "vol2"], ["two", "vol3"]]
irb(main):029:0> test.grep(/one/)
=> []
irb(main):030:0> test.each.grep(/one/)
=> []
irb(main):031:0> test
=> [["one", "vol1"], ["one", "vol2"], ["two", "vol3"]]
irb(main):032:0> test.grep('one')
=> []
irb(main):033:0> test2 = ['one', 'one', 'two', 'three']
=> ["one", "one", "two", "three"]
irb(main):034:0> test2.grep(/one/)
=> ["one", "one"]
irb(main):035:0>