You&#x27;re right that pattern-matching in functional languages resembles a switch statement. In a way it generalizes the concept of a switch statement, in the sense of &quot;doing different things based on the shape of the object at runtime.&quot; However, it&#x27;s quite a bit more powerful.<p>Here&#x27;s a simple and oft-used example, which is option types. They correspond roughly to nulls so let&#x27;s compare two blocks of pseudocode:<p><pre><code>    &#x2F;&#x2F; traditional
    if myValue == null:
      print(&quot;nothing here!&quot;)
    else:
      print(&quot;value is &quot; ++ myValue)

    &#x2F;&#x2F; with pattern-matching
    switch myValue:
      case None:
        print(&quot;nothing here!&quot;)
      case Some(thing):
        print(&quot;value is &quot; ++ thing)
</code></pre>
The two appear similar on the surface, but in the first example, we are <i>relying</i> on the programmer to check that myValue is not null. If he or she fails to check this, we&#x27;ll likely throw an exception or worse. On the other hand in the second case, we do not need to trust anyone; instead we <i>guarantee</i> that there will be a non-null value added to the string, because it won&#x27;t be possible to &quot;extract&quot; the inner value from myValue without entering a context in which myValue has a `Some` form. There is a lot more safety this way, since it&#x27;s guaranteed by the language rather than the programmer. And not only is it more safe, but it&#x27;s a lot clearer and more expressive as well. Consider a type with more than two variants, or holding multiple internal values rather than just one. The imperative if&#x2F;then&#x2F;else solution rapidly becomes verbose, obscure and error-prone, while the pattern matching case is just as straightforward as the above example.<p>It might seem weird on the surface but after a few times using it it&#x27;s the simplest thing in the world and you&#x27;ll wish you had it in other languages. In fact, Rust, which isn&#x27;t (primarily anyway) a functional programming language, makes heavy use of pattern matching.