3 ms·
I actually encountered this in Scala (my example originally had [square brackets] rather than <pointy ones>). My `.has` method uses cats.Eq and is monkey-patch
by chriswarbo 6y ago
I actually encountered this in Scala (my example originally had [square brackets] rather than <pointy ones>).
My `.has` method uses cats.Eq and is monkey-patched on to the Iterable interface:
implicit final class IOps[A: cats.Eq](val i: Iterable[A]) {
def has(x: A): Boolean = i.exists(_.eqv(x))
}
- blandflakes 6y agoHa, yup. We use the .contains_ method with cats eq on the objects, but this is clever.