On Tuesday, 5 December 2017 at 14:34:57 UTC, Mengu wrote:
On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote:
On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote:
[...]

Yes, this is not what I want. I want to convert only the first letter of the word to lower case and left all the others immutable. similar to PHP's lcfirst():

http://php.net/manual/en/function.lcfirst.php

this is how i'd do it:

string upcaseFirst(string wut) {
  import std.ascii : toUpper;
  import std.array : appender;

  auto s = appender!string;
  s ~= wut[0].toUpper;
  s ~= wut[1..$];
  return s.data;
}

however a solution that does not allocate any memory would be a lot better.

Reply via email to