小编not*_*bot的帖子

如何解决函数签名中的“UndefVarError:T 未定义”

我正在尝试运行(其他人的代码),看起来像

function f{T<:Number}(n::Int, alpha::T, beta::T)
    ...
end
Run Code Online (Sandbox Code Playgroud)

当“使用”该文件时,我得到

UndefVarError: T not defined
Stacktrace:
 [1] top-level scope at [file location]:[line number of function definition above]
Run Code Online (Sandbox Code Playgroud)

从我在文档(https://docs.julialang.org/en/v1/base/numbers/)中读到的内容来看,上面的语法看起来是正确的。知道为什么我会收到此错误吗?

types julia

6
推荐指数
1
解决办法
1191
查看次数

如何获取Julia中从1到n的数字列表?

在MATLAB中,您可以编写1:n。朱莉娅(Julia)中是否有与此表达类似的东西?

range julia

5
推荐指数
2
解决办法
110
查看次数

标签 统计

julia ×2

range ×1

types ×1