Why is string.front dchar?

TheFlyingFiddle kurtyan at student.chalmers.se
Wed Jan 15 12:05:31 PST 2014


On Tuesday, 14 January 2014 at 01:12:40 UTC, bearophile wrote:
> TheFlyingFiddle:

> But for backwards compatibility reasons in this code:
>
> foreach (c; "somestring")
>
> c is a char, not a dchar. You have to type it explicitly to 
> handle the UTF safely:
>
> foreach (dchar c; "somestring")

This is why i was confused really since the normal foreach is 
char it's weird that string.front is not a char. But if foreach 
being a char is only the way it is for legacy reasons it all 
makes sense.


More information about the Digitalmars-d-learn mailing list