View source code
							
							
						
								Display the source code in std/experimental/typecons.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Alias std.experimental.typecons.Final
Type constructor for final (aka head-const) variables.
						
				alias Final(T)
				 = T;
						
					
				Final variables cannot be directly mutated or rebound, but references
reached through the variable are typed with their original mutability.
It is equivalent to final variables in D1 and Java, as well as
readonly variables in C#.
When T is a const or immutable type, Final aliases
to T.
Example
Final can be used to create class references which cannot be rebound:
static class A
{
    int i;
    this(int i) pure nothrow @nogc @safe
    {
        thisExample
Final can also be used to create read-only data fields without using transitive immutability:
static class A
{
    int i;
    this(int i) pure nothrow @nogc @safe
    {
        thisAuthors
Andrei Alexandrescu, Bartosz Milewski, Don Clugston, Shin Fujishiro, Kenji Hara
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.