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.
···
--
Iñaki Baz Castillo
<ibc@aliax.net>
Of course I mean a method which perhaps I miss in Array class. If not,
I can do it manually 
···
2011/7/19 Iñaki Baz Castillo <ibc@aliax.net>:
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"]
--
Iñaki Baz Castillo
<ibc@aliax.net>
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 Tue, Jul 19, 2011 at 12:14 PM, Iñaki Baz Castillo <ibc@aliax.net> 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"]
arrayA | arrayB should do the trick
···
2011/7/19 Iñaki Baz Castillo <ibc@aliax.net>
2011/7/19 Iñaki Baz Castillo <ibc@aliax.net>:
> 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 
--
Iñaki Baz Castillo
<ibc@aliax.net>
damn. arrayA & arrayB is it.
···
2011/7/19 Gunther Diemant <g.diemant@gmx.net>
arrayA | arrayB should do the trick
2011/7/19 Iñaki Baz Castillo <ibc@aliax.net>
2011/7/19 Iñaki Baz Castillo <ibc@aliax.net>:
> 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 
--
Iñaki Baz Castillo
<ibc@aliax.net>
That would be the union. He's looking for Array#&
Jesus.
···
On Tue, Jul 19, 2011 at 12:19 PM, Gunther Diemant <g.diemant@gmx.net> wrote:
arrayA | arrayB should do the trick