find() [==/!=] None
with exists()
SC-R1009find()
allows you to look for elements in a collection that satisfy the provided condition/predicate. However, if you only need to determine whether elements matching your predicate exist, it is suggested that you directly use exists()
as it is slightly more efficient, readable, and easy to maintain.
if (nums.find(x => x % 5 == 0 && x >= 10) != None) {
// ...
}
if (nums.exists(x => x % 5 == 0 && x >= 10)) {
// ...
}