Martin Odersky illustrates this very same problem in his scala course very well:<p><a href="https:&#x2F;&#x2F;class.coursera.org&#x2F;progfun-002" rel="nofollow">https:&#x2F;&#x2F;class.coursera.org&#x2F;progfun-002</a><p>Lecture 4.5 Decomposition<p>Lecture 4.6 Pattern matching<p>(ps. I am not associated with Coursera or Martin in any way, just found his particular explanations very easy to understand)<p>Edit: formatting