When I do an intersection of two arrays, is there any guarantee that the resulting order is based on the order of the first array?
For example, if I have
a = [1,2,3]
b = [3,2,1]
could a & b
return [3,2,1]
, instead of [1,2,3]
(which is what I'd expect)?
I can't find anything directly addressing this in either RDoc's or the Pickaxe's documentation of Array.
RubySpec has a specification that it creates an array with elements in order they are first encountered, but should I assume YARV Ruby will honour that specification?
Looks like it is a guaranteed feature. They upgraded the RDoc description in revision 39415. It should be reflected sometime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With