Skip to content
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
29 changes: 16 additions & 13 deletions doc/src/manual/variables-and-scoping.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,21 +733,24 @@ object (such as an array), and that object may still be modified. Additionally w
to assign a value to a variable that is declared constant the following scenarios are possible:

* Attempting to replace a constant without the const `keyword` is disallowed:
```jldoctest
julia> const x = 1.0
1.0

julia> x = 1
ERROR: invalid assignment to constant x. This redefinition may be permitted using the `const` keyword.
```
* All other defefinitions of constants are permitted, but may cause significant re-compilation:
```jldoctest
julia> const y = 1.0
1.0
```jldoctest
julia> const x = 1.0
1.0

julia> const y = 2.0
2.0
```
julia> x = 1
ERROR: invalid assignment to constant x. This redefinition may be permitted using the `const` keyword.
```

* All other definitions of constants are permitted, but may cause significant re-compilation:

```jldoctest
julia> const y = 1.0
1.0

julia> const y = 2.0
2.0
```

!!! compat "Julia 1.12"
Prior to julia 1.12, redefinition of constants was poorly supported. It was restricted to
Expand Down