3 ms·
Incidentally, this functionality is but a subset of Erlang/Haskell style pattern matching, which does seem to be very helpful in many circumstances (unlike, as
by DaniFong 18y ago
Incidentally, this functionality is but a subset of Erlang/Haskell style pattern matching, which does seem to be very helpful in many circumstances (unlike, as is rumored, at least by PG, prolog's pattern matching). It's actually a favorite feature of mine: one that I'd like to put into any language I'd settle into.
- olavk 18y agoProlog-style pattern matching is quite helpful, at least in Prolog :) I think Haskell-style might be a subset of Prolog-style. Python-style is destructuring without pattern-matching, so its not really the same. The assignment will be executed whether the structures match or not - if they don't match (e.g. the right hand value is not a list or does not have the right size) an exception is raised. Pattern matching would not be that useful in Python anyway I suppose (unless you program Python as if it was Haskell)