I want to to put the first letter of a string into lowercase in D.
As a string is imutable in D, there doesn't seem to be a simple way.
I came up with this:
string mystr = "BookRef";
string outval = toLower( mystr[0..1] ) ~ mystr[1..$];
writeln( "my outval: ", outval );
Is there an easier way ?
While D string
s are immutable, you can use char[]
instead:
char[] mystr = "BookRef".dup; // .dup to create a copy
mystr[0] = toLower(mystr[0..1])[0];
writeln("my outval: ", mystr);