gpt4 book ai didi

ruby - 被调用的方法 `...'定义在这里

转载 作者:行者123 更新时间:2023-12-04 18:00:26 24 4
gpt4 key购买 nike

Ruby 2.7 刚刚发布,它带有这些关于“位置和关键字参数分离”的新警告(参见他们的 Release Post)。
我在玩弄它,发现还有另一个警告,我不明白。

例子:

def multiply(x:, y:)
x * y
end

args = { x: 2, y: 3 }

multiply(args)

# ./warning.rb:7: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
# ./warning.rb:1: warning: The called method `multiply' is defined here

我认为关于弃用的第一个警告是明确的,但第二个警告 The called method `multiply' is defined here对我来说很困惑。

第二个警告是什么意思?和第一个警告有关吗?

添加 ** 时,这两个警告都会消失到电话 ( multiply(**args) )。

最佳答案

What does the second warning mean? Is it related to the first warning?



有一个警告,文本分为两行。它的字面意思是: args应转换为 **args ,这是产生此警告的调用,为了您的方便,这是其定义。

关于ruby - 被调用的方法 `...'定义在这里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59490108/

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