Using std.conv.to with enum that is based on string type

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 19 05:31:03 PDT 2014


> 1. So I want to know if it is expected behaviour?

Yes, this was the chosen behaviour.


> 2. What are the reasons for it?

It's one of the two main behaviours you may want, even if your 
specific case it is not. It can be used to unserialize enums from 
a text file. This is the principle behind the text/to pair of 
functions, and this was copied by the repr of Python.

Bye,
bearophile


More information about the Digitalmars-d mailing list