I like Muldec's answer as I personally find switch statements to be a bit awkward to read. I also like the option of having a default so you could 'kind of' redefine the switch statement. The additional benefit is that you can use it inline as an expression and it is still typesafe...like this.
case2(myInputValue,
{
"http://www.example.com/1": "example",
"http://www.example.com/2": "another example",
"http://www.example.com/3": "yet another one",
}, "www.google");
The case2 code could be
TValue case2<TOptionType, TValue>(
TOptionType selectedOption,
Map<TOptionType, TValue> branches, [
TValue defaultValue = null,
]) {
if (!branches.containsKey(selectedOption)) {
return defaultValue;
}
return branches[selectedOption];
}