That's what the documentation states, anyway.
http://pike.ida.liu.se/generated/manual/ref/chapter_4.html#4:
When intersection, union or symmetric difference is used on an array each element in the array is considered by itself. So intersecting two arrays will result in an array with all elements that are present in both arrays. Example: ({7,6,4,3,2,1}) & ({1, 23, 5, 4, 7}) will return ({7,4,1}). The order of the elements in the returned array will always be taken from the left array.
...but it's been broken for ages. Those who want a workaround can use a + (b - a) instead of a | b but I'd rather see the bug fixed.
(While looking through the module reference for `| I also noticed that it incorrectly says that it performs _concatenation_ if the arguments are arrays.)
/ Jonas Walldén
Previous text:
2002-12-03 19:06: Subject: `| and order on arrays
I thought `| should keep the order when used on arrays:
Pike v7.3 release 62 running Hilfe v3.5 (Incremental Pike Frontend)
({1,2,3}) | ({2,4,1,17});
(1) Result: ({ /* 5 elements */ 3, 2, 4, 1, 17 })
Looks like it keeps the order in the second array, but the remaining elements in the first are swapped in this case. I furthermore expected the elements in the first array to remain unchanged with precedence over those in the second, since that makes it behave more consistently when used as |=, in which case all the elements in the left operand would remain on the same indices.
Wasn't this discussed and supposedly fixed some time ago (half a year or so)?
/ Martin Stjernholm, Roxen IS