4 ms·
1. each case of the pattern matching is encoded by a lambda (the ones passed to "shape" in function "area") 2. each possible shape instance is a function that
by chombier 6y ago
1. each case of the pattern matching is encoded by a lambda (the ones passed to "shape" in function "area")
2. each possible shape instance is a function that will accept these case lambdas, picking the one corresponding to it and passing its constructor arguments to it
3. the constructors ("Circle", "Rectangle") create the shape instances