我想定义一个结构:
struct unit_SI_gen
x::Float32
const c = 2.99792458e8
speed(x)=c*x
end
Run Code Online (Sandbox Code Playgroud)
但是,它引发了一个错误:
syntax: "c = 2.99792e+08" inside type definition is reserved
Run Code Online (Sandbox Code Playgroud)
我知道我不能在 python 中使用 struct 作为类,但我找不到如何解决这个问题。
如何在 struct 中定义常量?
julia ×1