3 ms·
(words.foldLeft(false)( _ || tweet.contains(_) )) > || . . . in every other language that means "logical or". What non-intuitive connotation does it have here?
by saurik 15y ago
(words.foldLeft(false)( _ || tweet.contains(_) ))
> || . . . in every other language that means "logical or". What non-intuitive connotation does it have here?
The "non-intuitive connotation" || has here is "logical or". The idea of "foldLeft" is that you are taking the previous value and operating on it to obtain the next value. In this case, you start with "false" (the default assumption: that the string does not contain any of the words) and then check, one by one, whether any of the words are in the tweet: for each word, you || the new result against the previous value.