Hi, is there a way to generate a new array with the common elements in
array A and arra B? This is:
arrayA = [“qqq”, “www”, “eee”]
arrayB = [“www”, “eee”, “rrr”, “ttt”]
the result should be: [“www”, “eee”]
Thanks a lot.
Hi, is there a way to generate a new array with the common elements in
array A and arra B? This is:
arrayA = [“qqq”, “www”, “eee”]
arrayB = [“www”, “eee”, “rrr”, “ttt”]
the result should be: [“www”, “eee”]
Thanks a lot.
2011/7/19 Iñaki Baz C. [email protected]:
Hi, is there a way to generate a new array with the common elements in
array A and arra B? This is:arrayA = [“qqq”, “www”, “eee”]
arrayB = [“www”, “eee”, “rrr”, “ttt”]the result should be: [“www”, “eee”]
Of course I mean a method which perhaps I miss in Array class. If not,
I can do it manually
On Tue, Jul 19, 2011 at 12:14 PM, Iaki Baz C. [email protected]
wrote:
Hi, is there a way to generate a new array with the common elements in
array A and arra B? This is:arrayA = [“qqq”, “www”, “eee”]
arrayB = [“www”, “eee”, “rrr”, “ttt”]the result should be: [“www”, “eee”]
ruby-1.8.7-p334 :001 > arrayA = [“qqq”, “www”, “eee”]
=> [“qqq”, “www”, “eee”]
ruby-1.8.7-p334 :002 > arrayB = [“www”, “eee”, “rrr”, “ttt”]
=> [“www”, “eee”, “rrr”, “ttt”]
ruby-1.8.7-p334 :003 > arrayA & arrayB
=> [“www”, “eee”]
Jesus.
On 19 juil. 2011, at 12:14, Iaki Baz C. wrote:
Hi, is there a way to generate a new array with the common elements in
array A and arra B? This is:arrayA = [“qqq”, “www”, “eee”]
arrayB = [“www”, “eee”, “rrr”, “ttt”]the result should be: [“www”, “eee”]
arrayC = arrayA & arrayB
El día 19 de julio de 2011 12:19, Jesús Gabriel y Galán
[email protected] escribió:
ruby-1.8.7-p334 :001 > arrayA = [“qqq”, “www”, “eee”]
=> [“qqq”, “www”, “eee”]
ruby-1.8.7-p334 :002 > arrayB = [“www”, “eee”, “rrr”, “ttt”]
=> [“www”, “eee”, “rrr”, “ttt”]
ruby-1.8.7-p334 :003 > arrayA & arrayB
=> [“www”, “eee”]
Ops, great
Thanks a lot.
On Tue, Jul 19, 2011 at 12:19 PM, Gunther D. [email protected]
wrote:
arrayA | arrayB should do the trick
That would be the union. He’s looking for Array#&
Jesus.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs