Compiler errors 字节和位运算符
我测试了代码:Compiler errors 字节和位运算符,compiler-errors,kotlin,byte,bitwise-operators,Compiler Errors,Kotlin,Byte,Bitwise Operators,我测试了代码: val a : Int = 0x01 val b : Int = 0x03 println(a and b) 得到: 1 但是如果我声明为Bytes: val a : Byte = 0x01 val b : Byte = 0x03 println(a and b) 出现错误: error: unresolved reference. None of the following candidates is applicable because of receiver type
val a : Int = 0x01
val b : Int = 0x03
println(a and b)
得到:
1
但是如果我声明为Byte
s:
val a : Byte = 0x01
val b : Byte = 0x03
println(a and b)
出现错误:
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)
^
我找到了参考资料:说:
平台和版本要求:Kotlin 1.1
我检查了我的版本:
C:\>kotlinc.bat -version
info: kotlinc-jvm 1.2.30 (JRE 1.8.0_181-b13)
这是什么意思?您缺少导入语句:
import kotlin.experimental.and
在没有导入的情况下,编译器会尝试使用
BigIntegers.kt中的和,为什么Intellj IDEA不建议这样做?:)