Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document mutable struct const fields #55203

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
giordano marked this conversation as resolved.
Show resolved Hide resolved
!!! 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