Enforced immutability: Difference between revisions
m
Regularize header markup to recommended on category page
m (→{{header|Phix}}: added one-off type checks, syntax colouring, marked p2js compatible) |
Thundergnat (talk | contribs) m (Regularize header markup to recommended on category page) |
||
Line 153:
It is possible to remove the <tt>const</tt> qualifier of the type a pointer points to through a cast, but doing so will result in undefined behavior.
=={{header|C sharp|C#}}==
Fields can be made read-only (a runtime constant) with the '''readonly''' keyword.
<lang csharp>readonly DateTime now = DateTime.Now;</lang>
Line 406:
constant str = "immutable string"</lang>
=={{header|F Sharp|F#}}==
As a functional language, everything in F# is immutable by default. Interestingly, <code>const</code> is a reserved word but is non-functional.
<lang fsharp>let hello = "Hello!"</lang>
|