Universal Function Call Syntax
Explore the Universal Function Call Syntax (UFCS) in D, which lets you call regular functions using member function syntax. Understand how this feature streamlines code, improves encapsulation, and enables intuitive chaining of function calls on types like classes and fundamental data.
We'll cover the following...
We'll cover the following...
Universal function call syntax (UFCS)
UFCS is a feature that is applied by the compiler automatically. It enables the member function syntax even for regular functions. It can be explained simply by comparing two expressions:
variable.foo(arguments)
When the compiler encounters an expression like the one above, if there is no member function named foo ...