最好用一个例子来解释:
我定义了一个类型
type myType
?::Float64
?::Float64
end
z = myType( 1., 2. )
Run Code Online (Sandbox Code Playgroud)
然后假设我想将此类型作为参数传递给函数:
myFunc( x::Vector{Float64}, m::myType ) =
x[1].^m.?+x[2].^m.?
Run Code Online (Sandbox Code Playgroud)
有没有办法传递,myType
以便我可以以"更清洁"的方式在函数体中实际使用它,如下所示:
x[1].^?+x[2].^?
Run Code Online (Sandbox Code Playgroud)
谢谢你的回答.
julia ×1