gpt4 book ai didi

scala - 为什么 .+() 方法在 scala 中被弃用?

转载 作者:行者123 更新时间:2023-12-02 21:35:28 25 4
gpt4 key购买 nike

只是想知道为什么我在 REPL 中看到以下内容:

scala> 5.+(9)警告:有 1 条弃用警告;使用 -deprecation 重新运行以获取详细信息res18:双倍 = 14.0

最佳答案

如果您按照说明操作并使用 scala -deprecation 运行 REPL,您将看到弃用的原因:

scala> 1 + 1
res0: Int = 2

scala> 1.+(1)
<console>:1: warning: This lexical syntax is deprecated. From scala 2.11,
a dot will only be considered part of a number if it is immediately followed
by a digit.
1.+(1)
^
res1: Double = 2.0

在 Scala 2.10.1 上测试

关于scala - 为什么 .+() 方法在 scala 中被弃用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21498021/

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