In Scala, you can use pattern matching to produce a result depending on the type of the input. For instance:
val title = content match { case blogPost: BlogP
Check out my pattern matching implementation: repo
It's based on expressions, so it offers equal perfomance with nested ifs.
Example usage:
string s1 = "Hello"; string s2 = null; Func> match = new Matcher> { {s => s is None, s => Console.WriteLine("None")}, {s => s is Some, s => Console.WriteLine((string)s) // or s.Value }; match(s1); // Hello match(s2); // None
Available throught NuGet: Nuget package