"contains" 和 "in" 之间的区别是什么 (Kotlin)

What is Diff between "contains" and "in" (Kotlin)

fun main() {
    val input = "ABC"
    val output = "ABC,"
    println(input.contains(output,false))
    print(input in (output))
}

输出:

false 
true

我刚刚检查过,incontains 使用相同的方法,但为什么给出不同的结果。

Kotlin contains 函数

Returns true if this char sequence contains the specified other sequence of characters as a substring.

实际上,您正在检查 input.contains(output)"ABC" 是否不包含 "ABC,"

正确的语法是

println(output.contains(input,false))