Can I check if a value is convertible to a valid value of an enum?

2015-09-24 Thread French Football via Digitalmars-d-learn
...without having to loop over the enum? enum SomeType : string { CHEESE = "cheese", POTATO = "potato" } string valid_value = "cheese"; string invalid_value = "pizza"; bool test( string value ){ if( value.isConvertableToSomeType ){ // this be the magic I seek //do something

Re: foreach automoatic counter?

2015-09-21 Thread French Football via Digitalmars-d-learn
On Monday, 21 September 2015 at 19:23:38 UTC, cym13 wrote: On Monday, 21 September 2015 at 16:32:25 UTC, French Football wrote: [...] I had to look into phobos sources (/usr/include/dlang/dmd/std/containers/dlist.d) to find a unittest, and judging from it it seems inserting in the middle

foreach automoatic counter?

2015-09-21 Thread French Football via Digitalmars-d-learn
Going through a book on coding in D, http://ddili.org/ders/d.en/foreach.html , I find the following very useful feature: When two names are specified in the names section [with a plain array], they represent an automatic counter and the value of the element, respectively: foreach (i,

Re: foreach automoatic counter?

2015-09-21 Thread French Football via Digitalmars-d-learn
On Monday, 21 September 2015 at 15:54:06 UTC, Justin Whear wrote: On Monday, 21 September 2015 at 15:58:12 UTC, cym13 wrote: Thankyou! .enumerate lets me iterate over a container with a counter. --Related tangential question... If I have a DList, how do I insert into the middle of it?