我测试了代码:
val a : Int = 0x01
val b : Int = 0x03
println(a and b)
Run Code Online (Sandbox Code Playgroud)
得到了:
1
Run Code Online (Sandbox Code Playgroud)
但如果我宣布为Byte
s:
val a : Byte = 0x01
val b : Byte = 0x03
println(a and b)
Run Code Online (Sandbox Code Playgroud)
得到错误:
error: unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
@SinceKotlin @InlineOnly public inline infix fun BigInteger.and(other: BigInteger): BigInteger defined in kotlin
println(a and b)
^
Run Code Online (Sandbox Code Playgroud)
我找到了参考:https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.experimental/and.html说:
平台和版本要求:Kotlin 1.1
我检查了我的版本:
C:\>kotlinc.bat -version
info: kotlinc-jvm …
Run Code Online (Sandbox Code Playgroud)