replace switch for mapping

Andrea Fontana via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 5 00:55:15 PDT 2017


On Monday, 4 September 2017 at 20:54:27 UTC, EntangledQuanta 
wrote:
> On Monday, 4 September 2017 at 09:23:24 UTC, Andrea Fontana 
> wrote:
>> On Thursday, 31 August 2017 at 23:17:52 UTC, EntangledQuanta 
>> wrote:
>>> Generally one has to use a switch to map dynamic components. 
>>> Given a set X and Y one can form a switch to map X to Y:
>>>
>>> [...]
>>
>> Does this work for you?
>> https://dpaste.dzfl.pl/e2669b595539
>>
>> Andrea
>
> No, do you realize you are passing those enums at compile time? 
> It won't work if they are "runtime" variables, which is the 
> whole point of doing all this. You've essentially make a simple 
> problem complicated. Why not just overload foo properly?

So at runtime you can do in a couple of ways if i'm right:
http://dpaste.com/02W9FX6

Andrea



More information about the Digitalmars-d-learn mailing list