robrix / Hammer

Parsing and pattern matching in Objective-C
BSD 3-Clause "New" or "Revised" License
75 stars 1 forks source link

README example of destructuring pattern matching #81

Open robrix opened 10 years ago

robrix commented 10 years ago

Would show using Hammer to destructure e.g. a dictionary:

[self addSubview:HMRMatch(petsByName, @[
    [HMRPair(HMRAny(), HMRBind(HMRProperty(@"fluffiness", @(ExtremeFluffiness)))) then:^(Pet *pet) {
        return [PetView petViewWithExtremelyFluffyPet:pet];
    }],
])];

Depends on #78 probably.

robrix commented 10 years ago

That pseudocode is illustrating a few things that don’t exist: