From 042230a83a85c2a747b039854d085dd1c1adc21d Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Sun, 21 Jul 2024 18:53:08 -0400 Subject: [PATCH] document mutable struct const fields --- base/docs/basedocs.jl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 37804d1d9a380..d5311768124f9 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -1447,8 +1447,20 @@ kw"struct" mutable struct `mutable struct` is similar to [`struct`](@ref), but additionally allows the -fields of the type to be set after construction. See the manual section on -[Composite Types](@ref) for more information. +fields of the type to be set after construction. + +Individual fields of a mutable struct can be marked as `const` to make them immutable: + +```julia +mutable struct Baz + a::Int + const b::Float64 +end +``` +!!! compat "Julia 1.8" + The `const` keyword for fields of mutable structs requires at least Julia 1.8. + +See the manual section on [Composite Types](@ref) for more information. """ kw"mutable struct"