On this documentation page of interfaces on dlang.org, it says interfaces must implement final methods. What are final methods? The keyword doesn't seem to be mentioned on any other page.
There is this page I found, but it seems to be a remain from the ancient D1.
Is a final function simply a function returning an immutable result? Does the keyword even still exist?
The final keyword is a non-access modifier used for classes, attributes and methods, which makes them non-changeable (impossible to inherit or override). The final keyword is useful when you want a variable to always store the same value, like PI (3.14159...). The final keyword is called a "modifier".
You use the final keyword in a method declaration to indicate that the method cannot be overridden by subclasses. The Object class does this—a number of its methods are final .
What Does Final Mean? Final is a keyword which is used to define an entity that cannot be changed nor derived from later. The final keyword is used in three different contexts. For example, afinal class, final method, andfinal variables.
The finally keyword is used in try... except blocks. It defines a block of code to run when the try... except...else block is final. The finally block will be executed no matter if the try block raises an error or not.
From Virtual Functions:
Functions marked as
final
may not be overridden in a derived class, unless they are alsoprivate
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With