什么是Kotlin中的指数运算符.我认为它会,**
但它似乎在我的代码中引发错误.
when (pendingOperation) {
"=" -> operand1 = value
"÷" -> operand1 = if (value == 0.0) {
Double.NaN // handle attempt to divide by zero
} else {
operand1!! / value
}
"x" -> operand1 = operand1!! * value
"?" -> operand1 = operand1!! - value
"+" -> operand1 = operand1!! + value
"a^b" -> operand1 = operand1!! ** value
Run Code Online (Sandbox Code Playgroud) 我正试图在Kotlin写一些小东西,但我遇到了找到数字的二次幂的问题Double
.
根据这个,Double
应该实现一个pow
接收另一个的函数Double
,但是当我尝试使用这个方法时我得到Unresolved reference: pow
了一个错误.
这是我的示例代码:
fun main()
{
val d: Double = 1.1;
val d2: Double = d.pow(2.0); // Here's the error, on the token 'pow'.
println(d2);
}
Run Code Online (Sandbox Code Playgroud)
我找不到任何理由.此功能仅来自Kotlin 1.2,但Eclipse安装详细信息中的Kotlin记录说Kotlin language support for Kotlin 1.2.50
.
我创建的项目,我更新了科特林插件之前,它是可能的项目,以科特林版本创建的1.2之前,但我不能在设置中找到的任何位置改变配置科特林版本,所以我想使用的版本是一个即安装1.2 .50
顺便说一句,Eclipse提供的错误图标是灯泡1的错误,表明存在可用的解决方案,但是当我点击图标时没有出现,这很奇怪.
如果有人能提出任何理由,那就太好了.
提前致谢.