tst*_*tst 9 struct types julia
让我们定义4个不同类别的点:
type PointType
x
y
end
mutable struct PointMut
x
y
end
immutable PointImmut
x
y
end
struct PointStruct
x
y
end
Run Code Online (Sandbox Code Playgroud)
PointType和之间有什么区别PointMut?为什么有人会选择一个而不是另一个?
此外之间有什么区别PointImmut和PointStruct?
我倾向于认为它们只是同义词,但我没有明确地说明这一点,所以我想知道某处是否存在隐藏的细微差别.
Mic*_*ard 29
type并且immutable在julia 0.6中有效,mutable struct并且struct是julia 0.6和forward中相同对象的名称.mutablein mutable struct表示字段可以更改 - 这实际上很少使用,因此不可变是默认值.mutable struct比structs 慢.
| 归档时间: |
|
| 查看次数: |
4302 次 |
| 最近记录: |