fix issue 9959 - Add functional pattern matching for object references

Add the function std.algorithm.castSwitch, which chooses a delegate
based on the class of an object and run that delegate with that object.
Merge pull request #1266 from idanarye/add-functional-pattern-matching-for-object-references

fix issue 9959 - Add functional pattern matching for object references