4 ms·
What does getSquare (Math _ square _) = square mean?
by angeladur 14y ago
What does getSquare (Math _ square _) = square mean?
- chrisdone 14y agoThat's a pattern match. Math is a data constructor, it makes a Math object. It takes three arguments. So (Math 1 2 3) is a Math object. A pattern is a way of deconstructing an object into its constituent parts and bringing some of those into scope.So (Math x y z) is a valid pattern, which would bring these values into scope: x=1, y=2, z=3. In this case I'm bringing only the second argument into scope. In a pattern, _ means "ignore this argument". Here is a short interactive lesson on pattern matching: http://tryhaskell.org/#19 http://tryhaskell.org/#19