...ing logging 3.0 このページをアンテナに追加 RSSフィード

January 25(Mon), 2010

inout(type)[] or inout(type[])?

http://www.digitalmars.com/d/2.0/function.html

inout(int)[] foo(inout(int)[] a, int x, int y) { return a[x .. y]; }

ふむ.


import std.stdio;

inout(int)[] f(inout(int)[] a, int x, int y)
{
	return a[x .. y];
}

void main()
{
	auto b = f([1,2,3,4,5,6,7][], 1, 3);
	writeln(b);
}
hello.d(10): Error: function hello.f (inout(int)[] a, int x, int y) is not callable using argument types (int[],int,int)
hello.d(10): Error: cannot implicitly convert expression ([1,2,3,4,5,6,7][]) of type int[] to inout(int)[]

んー?


import std.stdio;

inout(int[]) f(inout(int[]) a, int x, int y)
{
	return a[x .. y];
}

void main()
{
	auto b = f([1,2,3,4,5,6,7][], 1, 3);
	writeln(b);
}

こうするといけた.

どうでもいいが[]を半角でタイトルに書くにはどうしたらいいんだ・・・.

2010/03/17

これか?

http://hatenadiary.g.hatena.ne.jp/keyword/%E8%87%AA%E5%8B%95%E3%83%AA%E3%83%B3%E3%82%AF%E3%82%92%E6%AD%A2%E3%82%81%E3%82%8B%EF%BC%88%E8%87%AA%E5%8B%95%E3%83%AA%E3%83%B3%E3%82%AF%E5%81%9C%E6%AD%A2%E8%A8%98%E6%B3%95%EF%BC%89


というわけで説明を書いた.

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証