if line.include?(destination) && line.include?(location) if [destination,location].all?{ |o| line.include?(o) } if ([destination,location] & line).length == 2
The first is the clearest, but least DRY.
The latter is the least understood, but the fastest, when you have several items to check. (This is O(m+n) vs O(m*n) .)
I would use medium if speed were not of primary importance.
source share