Trailing Lambda
When the last parameter of a function is a function type, the lambda can be written outside the parentheses when calling. This syntax is called trailing lambda, making the code look more like built-in language syntax and improving readability.
If a function has only one parameter and that parameter is a function type, the parentheses () can even be omitted entirely, writing only the lambda. This is particularly useful when defining DSLs (domain-specific languages) and builder patterns.
In the example on the right, myIf's second parameter is a function type, and line 20 calls it using trailing lambda syntax. applyTwice has only one function parameter, and line 24 omits the parentheses, writing the lambda directly. Both forms are equivalent to the conventional call syntax.
The => of a trailing lambda can be omitted when the function body is a single expression. Compare line 22 and line 25: multi-line lambdas are clearer, while single expressions can be more concise.
Try rewriting line 24 to conventional call syntax applyTwice({ value => value + 3 }) to understand the equivalence of both forms.