Universal Function Call Syntax
You will get to learn about universal function call syntax (UFCS) in this lesson.
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
that can be called on a variable with the provided arguments, the compiler also tries to compile the following expression:
foo(variable, arguments)
If this new expression can be compiled, the compiler simply accepts that one. As a result, foo()
gets accepted to be used by the member function syntax even ...