(Smacks forehead). All I needed for you to say was "type(of: someAny)". I was stupidly thinking it would return "dude, it's an Any!" but of course it returns the type of the underlying object.
That's all one needs, and is the equivalent of what I was saying in C++ about getting a std::type_info. Armed with that, I can indeed look up the work function in a dictionary.
But should I? switch statements in C/C++ do indeed do some sort of a jump table thing, but that's basically just mapping an int to something else. Is the Swift compiler smart enough to do something equivalent for cases where you're casting the contents of an Any? If so, I'd happily use the switch formulation because I can enumerate all the type cases in my switch. If it evaluates sequentially though, I'd opt for a map.
I guess the right answer is write both, time them, and see which is better. I should probably give that a try and report back!
Reporting back: I made a map with 10 types, and compared it to using a switch statement that enumerated the 10 casts as cases in the switch.
If the type passed in is the first case in the switch statement, the running time was 0.43 seconds (over some large number of iterations). If the type was the last case of the switch statement, running time was 4.3 seconds.
In the map case, running time was approx 2.3 seconds, no matter what the type was.