and that `in` keyword can be used in a `when` for ...
# announcements
k
and that
in
keyword can be used in a
when
for any
operator fun contains
, whether it's defined as
String.contains
,
List.contains
, your own custom type's
contains
function, etc
a
Would an example be:
Copy code
when (charInput) {
  in "Adam" -> println("Yay")
  else -> println("Nope")
}
k
well
charInput in "Adam"
is equivalent to saying
"Adam".contains(charInput)
(in all instances, not just in a
when
, this is a standard Kotlin operator), so for example, "A" would hit your "Yay" block in this case, but "Adam McNeilly" would hit your "Nope" block
but that when block is valid syntax, yes
a
Right, I was just tyring to equate `charInput in "MyString" with
contains
which I didn't know was true. This is neat.