gpt4 book ai didi

julia - 方法错误 : objects of type Float64 are not callable

转载 作者:行者123 更新时间:2023-12-05 00:10:51 24 4
gpt4 key购买 nike

我做了一个函数来查找球体的体积:

function volume_sphere(r)
(4/3)(round(π, sigdigits=6))(r)^3
end

julia> println(volume_sphere(5))

我收到此错误消息:

ERROR: MethodError: objects of type Float64 are not callable
Stacktrace:
[1] volume_sphere(::Int64) at C:\Users\Practice.jl:27
[2] top-level scope at none:0



问题从何而来?

最佳答案

这个问题详细解释here .
总之,您不能省略 *在两个带括号的表达式并列时,也不在带括号的表达式之前放置变量时。因此这是一个有效的代码:

4/3*round(π, sigdigits=6)*r^3
但是你可以写例如 2r+3(r^2+1)r这将是一个有效的代码行。

关于julia - 方法错误 : objects of type Float64 are not callable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56211189/

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