Logo

Programming-Idioms

History of Idiom 218 > diff from v7 to v8

Edit summary for version 8 by steenslag:
[Ruby] Alternative 2.7 method name

Version 7

2020-01-14, 21:07:17

Version 8

2020-01-19, 00:56:09

Idiom #218 List intersection

Create list c containing all unique elements that are contained in both lists a and b.
c should not contain any duplicates, even if a and b do.
The order of c doesn't matter.

Idiom #218 List intersection

Create list c containing all unique elements that are contained in both lists a and b.
c should not contain any duplicates, even if a and b do.
The order of c doesn't matter.

Extra Keywords
intersect and conjunction
Extra Keywords
intersect and conjunction
Code
c = a & b
Code
c = a & b
Comments bubble
Ruby 2.7 introduced an alias: c = a.intersection(b)
Doc URL
https://ruby-doc.org/core-2.7.0/Array.html#method-i-26
Doc URL
https://ruby-doc.org/core-2.7.0/Array.html#method-i-26
Demo URL
https://ideone.com/bZ3rvD
Demo URL
https://ideone.com/bZ3rvD