|
|
|
|
|
by barkmadley
5427 days ago
|
|
The desugaring process is what makes the for loop magic. I cannot write a different control structure that looks like the that for loop in scala without touching the compiler. A counter example that shows how to avoid the sugar would be "if expressions" in smalltalk (simplified, may differ to reality). In smalltalk, the abstract boolean class has a method 'if'. And the "true" subclass of the boolean class implements the 'if' method to execute its first parameter, while the "false" subclass implements the 'if' method to execute its second parameter. |
|