From 6b08e80bd1217c5c2eb6c89604c21faa5b2a156f Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 22 Jul 2024 21:43:43 -0400 Subject: [PATCH] document mutable struct const fields (#55203) Introduced in https://github.com/JuliaLang/julia/pull/43305 --- 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 635f1765627fa..00e4a0afb5c0e 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -1451,8 +1451,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"