What are the useful inout free functions?

Guillaume Piolat via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 4 15:17:25 PST 2016


On Monday, 4 January 2016 at 23:15:22 UTC, Guillaume Piolat wrote:
> Can someone produce a _useful_ free function that uses inout?
>
> There are useful getters using inout.
> There are useless free functions using inout like 
> http://dpaste.dzfl.pl/d038012308ed

Adam D. Ruppe answered this on IRC:

inout(char)[] chomp(inout(char)[] str)
{
     return if(str.length && str[$-1] == '\n') str[0 .. $-1] : str;
}


More information about the Digitalmars-d-learn mailing list