Functions are generally code blocks that carry out certain instruction in an application. These blocks of code can be called multiple times during the runtime of the application whose functions are reusable.
property
functions?Member functions, such as member variables, can be used with properties. The @property
keyword is used to access these properties. The characteristics are associated with functions that return values based on the requirements. Let's look at an example of a property.
import std.stdio;struct Square {double objectWidth;double objectHeight;double objectArea() const @property {return objectWidth*objectHeight;}void objectArea(double newArea) @property {auto multiplier = newArea / objectArea;objectWidth *= multiplier;writeln("Value set!");}}void main() {auto square = Square(50,50);writeln("The area is ", square.objectArea);}
square
struct.@property
keyword.square
function.property
function and equate it to a variable