参考自d程序设计语言---个人博客http://my.oschina.net/u/218155/blog?fromerr=SwOkb7Sw fllow mespa
inout主要是用来推测是不是imutability,const,空类型的..net
咱们能够 inout(char)[]表明既能够是immutable(char)[] 也能够是 char[]有点相似泛型。可是他只做用于immutable设计
import std.stdio; void main() { string parenthesized1(string phrase) { return '(' ~ phrase ~ ')'; } writeln(parenthesized1("hiparenthesized")); char[] m; m ~= "hi"; //writeln(parenthesized(m)); char[] parenthesized2(char[] phrase) { return '(' ~ phrase ~ ')'; } writeln(parenthesized2(m)); const(char)[] parenthesized3(const(char)[] phrase) { return '(' ~ phrase ~ ')'; } writeln(parenthesized3(m)); inout(char)[] parenthesized(inout(char)[] phrase) { return '(' ~ phrase ~ ')'; } writeln(typeof("hiparenthesized").stringof); writeln(parenthesized("hiparenthesized")); writeln(typeof(m).stringof); writeln(parenthesized(m)); writeln(typeid(typeof("hiparenthesized"))); string c1(string s){ return '#'~s; } char[] c2(char[] s){ return '#'~s; } inout (char)[] c3(inout(char)[] s){ return '#'~s; } }