You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to make General Pattern Matcher to be able to match objects on types apart from values just like Union Pattern Matcher does with it's union cases (via CaseOf)?
abstract class ItemBase { }
class ItemA : ItemBase { }
class ItemB : ItemBase { }
class ItemC : ItemBase { }
ItemBase GetItem() { … }
var item = GetItem();
item.Match()
.WithType<ItemA>().Do(a => …)
.WithType<ItemB>().Do(b => …)
.WithType<ItemC>().Do(c => …)
.Exec();
I'm not really sure this is constructive, though, because C# 7.0 can pattern match types with the same purpose (via swtich).
The text was updated successfully, but these errors were encountered:
I agree there's little point in implementing this for Match ... Exec statements, as the C# 7 type matching additions to switch would cover this. However, there is likely benefit to adding Match .. Result expression support in the way you describe. We'll have to wait until at least C# v7.1 for the match expression equivalent.
Is it possible to make General Pattern Matcher to be able to match objects on types apart from values just like Union Pattern Matcher does with it's union cases (via CaseOf)?
I'm not really sure this is constructive, though, because C# 7.0 can pattern match types with the same purpose (via
swtich
).The text was updated successfully, but these errors were encountered: