Defining a static array with values in a range

tcak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 22 09:45:58 PST 2015


On Thursday, 22 January 2015 at 17:15:34 UTC, Jonathan M Davis 
via Digitalmars-d-learn wrote:
> On Thursday, January 22, 2015 15:16:07 bearophile via 
> Digitalmars-d-learn wrote:
>> Jonathan M Davis:
>>
>> > but that's easy fixed with some +1's.
>>
>> But the +1 changes the char to an int.
>
> True, though iota doesn't seem to like to operate on char 
> anyway, so from
> the little playing around with it I did to answer the OP, it 
> looks like
> you're forced to use casts for it anyway. And depending, you 
> probably want
> to cast to ubyte and then convert that to char when you convert 
> the range to
> an array to avoid the conversion to dchar anyway. So, all 
> around, trying to
> use iota with char is a bit awkward.
>
> - Jonathan M Davis

So, at the end of the day (I left working on my Matcher class in 
the morning waiting an answer for this question), there is 
nothing to convert ['a'..'d', '0'..'3'] to ['a', 'b', 'c', 'd', 
'0', '1', '2', '3'] at compile time automatically.


More information about the Digitalmars-d-learn mailing list