www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What are the useful inout free functions?

reply Guillaume Piolat <first.last gmail.com> writes:
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
Jan 04
parent Guillaume Piolat <first.last gmail.com> writes:
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; }
Jan 04