Skip to content

Commit

Permalink
Updated readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelGerr committed Aug 13, 2024
1 parent 1b5c189 commit 1fb005c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,26 @@ string key = ProductType.Groceries.ToString(); // "Groceries"
ILogger logger = ...;

// Switch-case (with "Action")
productType.Switch(ProductType.Groceries, () => logger.Information("Switch with Action: Groceries"),
ProductType.Housewares, () => logger.Information("Switch with Action: Housewares"));
productType.Switch(groceries: () => logger.Information("Switch with Action: Groceries"),
housewares: () => logger.Information("Switch with Action: Housewares"));

// Switch-case with parameter (Action<TParam>) to prevent closures
productType.Switch(logger,
ProductType.Groceries, static l => l.Information("Switch with Action: Groceries"),
ProductType.Housewares, static l => l.Information("Switch with Action: Housewares"));
groceries: static l => l.Information("Switch with Action: Groceries"),
housewares: static l => l.Information("Switch with Action: Housewares"));

// Switch case returning a value (Func<TResult>)
var returnValue = productType.Switch(ProductType.Groceries, static () => "Switch with Func<T>: Groceries",
ProductType.Housewares, static () => "Switch with Func<T>: Housewares");
var returnValue = productType.Switch(groceries: static () => "Switch with Func<T>: Groceries",
housewares: static () => "Switch with Func<T>: Housewares");

// Switch case with parameter returning a value (Func<TParam, TResult>) to prevent closures
var returnValue = productType.Switch(logger,
ProductType.Groceries, static l => "Switch with Func<T>: Groceries",
ProductType.Housewares, static l => "Switch with Func<T>: Housewares");
groceries: static l => "Switch with Func<T>: Groceries",
housewares: static l => "Switch with Func<T>: Housewares");

// Map an item to another instance
returnValue = productType.Map(ProductType.Groceries, "Map: Groceries",
ProductType.Housewares, "Map: Housewares");
returnValue = productType.Map(groceries: "Map: Groceries",
housewares: "Map: Housewares");
------------

// Implements IParsable<T> which is especially helpful with minimal apis.
Expand Down

0 comments on commit 1fb005c

Please sign in to comment.