3 ms·
designated initializers are a trap. you can't require certain fields are set... this has been a big pain point for my team. guess we should have used builder pa
by 8n4vidtmkvmk 4y ago
designated initializers are a trap. you can't require certain fields are set... this has been a big pain point for my team. guess we should have used builder pattern or something
- pjmlp 4y agoI would say constructors are what should be used for such kind of compound initializations. C# is going the route of allowing required/optional fields in designated initializers, and from my point of view it is just a mess for what should be a constructor call.
- leni536 4y ago> you can't require certain fields are set There is a way, but it's cursed: https://godbolt.org/z/fzc6WEz5e https://godbolt.org/z/fzc6WEz5e
- ncmncm 4y agoClever. Wrap it in a concept, and it might have legs.