fun main() {
val input = "ABC"
val output = "ABC,"
println(input.contains(output,false))
print(input in (output))
}
Output :
false
true
I just checked that, in
and contains
are using same method, but why giving difference results.
The Kotlin contains
function
Returns true if this char sequence contains the specified other sequence of characters as a substring.
Actually, you're checking if input.contains(output)
, and "ABC"
does not contain "ABC,"
.
The correct syntax is
println(output.contains(input,false))