gpt4 book ai didi

scala - .get(x)行为从何而来?

转载 作者:行者123 更新时间:2023-12-04 13:36:09 24 4
gpt4 key购买 nike

Some("abcdefg").get(3)  //res0: Char = d
get()的参数发送到 apply()String方法,但是 Option(和 Some)的 source code没有使用参数的 get()方法,而 String根本没有 get方法。

那么什么 get()被调用?它是 java 的一颗痣吗?

最佳答案

来自隐式转换的StringOps.apply

augmentString(Some("abcdefg").get)(3)

augmentString 在哪里
@inline implicit def augmentString(x: String): StringOps = new StringOps(x)

关于scala - .get(x)行为从何而来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56849408/

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