我在 Kotlin 代码中使用数学函数“min”来声明变量“toRemove”
val toRemove = min(preferredQuantity - taken, stock.quantity)
Run Code Online (Sandbox Code Playgroud)
错误消息:Kotlin 未解析的参考
1/我可以知道如何解决吗?
2/ 该函数在kotlin.math中,为什么我不能直接使用它? https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/
谢谢!
为了完整起见:正如 @Tenfour04 在评论中指出的那样,kotlin.math.min通过检查以下之一来确保导入
import kotlin.math.min
import kotlin.math.*
Run Code Online (Sandbox Code Playgroud)
位于文件顶部。该kotlin.math.*变体将从包中导入所有内容kotlin.math。请参阅有关导入的 Kotlin 文档页面。
| 归档时间: |
|
| 查看次数: |
4430 次 |
| 最近记录: |