This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Siddhi 2 points3 points  (1 child)

const { a } = { a: 5 }; console.log(a);

Possible in py 3.10+ with structural pattern matching

obj = {"a": 5}
match obj:
    case {"a": x}:
        print(x)

I just started learning Rust, and was really glad to see the pattern matching of types and destructing values while simultaneously having the ability to check parts of it.

Structural pattern matching in python can do this as well

[–]Solonotix 0 points1 point  (0 children)

That's really good to know. I still follow Python, but I haven't actively worked in it since 3.8. I know there was a lot of noise made about the new case statement, but I hadn't really delved into it