eclipse - 未解决的参考:在 Eclipse 中使用 Kotlin 的 pow
问题描述
我正在尝试在 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);
}
我找不到任何理由。此功能仅来自 Kotlin 1.2,但 Eclipse 安装详细信息中的 Kotlin 记录说Kotlin language support for Kotlin 1.2.50
。
我在更新 Kotlin 插件之前创建了该项目,并且该项目可能是为 1.2 之前的 Kotlin 版本创建的,但我无法在任何地方的设置中找到更改配置的 Kotlin 版本,所以我假设使用的版本是已安装的版本,即 1.2 .50。
顺便说一句,Eclipse 显示的错误图标是灯泡一的错误,表明存在可用的解决方案,但是当我单击该图标时没有显示,这很奇怪。
如果有人可以为此提出任何理由,那就太好了。
提前致谢。
解决方案
您需要将该函数pow
导入到您的文件中:
import kotlin.math.*
我的完整代码:
import kotlin.math.pow
fun main(args: Array<String>)
{
val d: Double = 1.1;
val d2: Double = d.pow(2.0); // Here's the error, on the token 'pow'.
println(d2);
}
推荐阅读
- ubuntu - 从端点写入或读取超时,以及通信格式问题(wireshark + pyusb)
- python - 通过组合框更改选项卡,反之亦然
- javascript - 如何在 Gridsome 页面/模板中嵌入 Wistia 频道视频库
- react-native - 如何从类组件调用堆栈导航器?
- sql-server - 能否使用 System Center Data Protection Manager 备份 Azure DevOps Server SQL Server 数据库?
- sql - ORACLE SQL中获取BLOB的图像格式
- java - 四舍五入与所有预期结果不匹配
- python - 列表理解用字典中的键字符串替换字符串中的值
- mysql - SELECT 语句中的 MYSQL 和 TOP 用法
- ios - 在 Info.plist 中配置场景时不使用 AppDelegate