Is it possible to do a negative infix operator? I ...
# announcements
j
Is it possible to do a negative infix operator? I currently have this operator:
infix operator fun contains(option: Option): Boolean
I would like to be able to write both cases
if (data contains MyOption)
and
if (data !contains MyOption)
g
Use
!in
if (MyOption in data)
j
I want to have custom logic
g
when you override
contains
you are overriding
in
same as when you override
plus
and you can also use
+
j
I wrote a quick sample here: https://pl.kotl.in/cgteZ-i_n
s
j
@Sergei Dubrov [JB] Exactly what I was looking for. No updates on that issue that last 2 years 😛
g
❤️ 1
1
j
ah, nice 👍 Didn't think that would work as it was a data class
g
a in b
is the same as
b contains a
The "operator form" is
in
j
Genius! Then I already had support for that. 😅
Thanks for the help
g
No problem!