Hacker News new | ask | show | jobs
by frou_dh 999 days ago
That's not particularly relevant to the nice pattern matching property I mentioned. If you need to manually write supplementary code to get the exhaustiveness safety then that's back into the realm of bog-standard defensive programming.

Here's what I mean. The Ruby will throw NoMatchingPatternError and the Python will silently do nothing.

    x = [10, "figs"]

    case x
    in [n, "apples"]
      :foo
    in [n, "oranges"]
      :bar
    end

    # ---

    x = [10, "figs"]

    match x:
        case [n, "apples"]:
                ...
        case [n, "oranges"]:
                ...
1 comments

You can use ‘case _’ in that case … it’s not a big deal to opt into this default behaviour.
I know, that's why I mentioned the manual part. What I'm getting from this exchange is that Python is your team and no criticism can be allowed to stand.
No I’m just trying to add substance to the discussion.

I like Ruby but I wouldn’t use it for the things I use Python for.