Skip to content

baks/PatternMatching

Repository files navigation

Simple Pattern Matching in C# Build status

Usage

Example for matching with actions:

var action = new MatchAction<string>
{
	{"a", s => Console.WriteLine("pattern a")},
	{s => s.StartsWith("d"), s => Console.WriteLine("pattern for string which starts with d ")},
	{ Match.Default, s => Console.WriteLine("default action") },
	{ Match.Null, s => Console.WriteLine("action for null") }
}.Action;
			
action("dummy");

Example for matching with funcs:

var func = new MatchAction<string>
{
	{"a", s => "pattern a")},
	{s => s.StartsWith("d"), s => "pattern for string which starts with d "},
	{ Match.Default, s => "default action" },
	{ Match.Null, s => "action for null" }
}.Func;
			
var result = func("dummy").Single();

About

Simple pattern matching in C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages