Skip to content

Commit

Permalink
document mutable struct const fields (#55203)
Browse files Browse the repository at this point in the history
Introduced in #43305

(cherry picked from commit 6b08e80)
  • Loading branch information
IanButterworth authored and KristofferC committed Jul 23, 2024
1 parent 35f56b1 commit 91976c2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1419,8 +1419,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"

Expand Down

0 comments on commit 91976c2

Please sign in to comment.