gpt4 book ai didi

kotlin - 为什么 UInt 没有 toDouble()?

转载 作者:IT老高 更新时间:2023-10-28 13:28:04 26 4
gpt4 key购买 nike

考虑:

val foo: Int = 1
foo.toDouble() // ok

val bar = 2.toUInt()
bar.toDouble() // error!

这对我来说没有意义。为什么 UInt 没有 toDouble? (它也没有 .toFloat)。

The docs say :

Every number type supports the following conversions:

  • toByte(): Byte
  • toShort(): Short
  • toInt(): Int
  • toLong(): Long
  • toFloat(): Float
  • toDouble(): Double
  • toChar(): Char

所以应该可以。我得到的错误是:

Error:(11, 4) Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
@InlineOnly public inline fun String.toDouble(): Double defined in kotlin.text

UInt 不被视为数字类型吗?还是别的什么?

最佳答案

根据 this YouTrack request,这似乎将在 1.3.30 中推出.

1.3.30 只是 recently tagged并且似乎很快就会发布。

关于kotlin - 为什么 UInt 没有 toDouble()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55636856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com