已定义的结构体,如何增加结构体字段?
技术分享
发布于 2025-07-15 11:57:04
查看 1过去349天
在定义前加上 Base.@kwdef,参考以下示例:
Base.@kwdef mutable struct Point2
x::Int = 0
y::Int = 0
z::Int = 0
end
point = Point2()
point.x = 1
point.y = 2
point

所属专栏:Julia语言
产品信息:Syslab科学计算环境
在定义前加上 Base.@kwdef,参考以下示例:
Base.@kwdef mutable struct Point2
x::Int = 0
y::Int = 0
z::Int = 0
end
point = Point2()
point.x = 1
point.y = 2
point
