Hi all
a = [:one, :two, :three, :six]
b = [:two, :four, six]
I want to extract the values of two arrays which exist in both ones (a
and b):
=> [:two, :six]
Does there exist a method for this?
Thanks
Josh
Hi all
a = [:one, :two, :three, :six]
b = [:two, :four, six]
I want to extract the values of two arrays which exist in both ones (a
and b):
Does there exist a method for this?
Thanks
Josh
On Nov 23, 1:25 pm, Joshua M. [email protected] wrote:
Does there exist a method for this?
Thanks
JoshPosted viahttp://www.ruby-forum.com/.
Try
a&b
Dima
How about the elements that are in one but not the other array?
Where are these methods documented?
Thank you
Victor
Thanks! But right - where are they documented?
You’re looking for “a - b”, in that case.
http://ruby-doc.org/core/classes/Array.html
Hope that helps.
Joshua M. wrote:
Thanks! But right - where are they documented?
in ruby-doc
Thank you
On Nov 23, 3:13 pm, Victor R. [email protected] wrote:
Hope that helps.
On Nov 23, 2007 7:55 AM, Dejan D. [email protected] wrote:
a&b
Dima
Programming Ruby
The Pragmatic Programmer’s Guide
class Array
instance methods
& arr & anOtherArray → anArray
Set Intersection—Returns a new array containing elements common to
the two arrays, with no duplicates.
[ 1, 1, 3, 5 ] & [ 1, 2, 3 ] >> [1, 3]
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