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://d.hatena.ne.jp/haru-s/20100125/1264450260
リンク元
- 7 http://d.hatena.ne.jp/
- 6 http://d.hatena.ne.jp/keyword/D言語
- 5 http://www.google.co.jp/reader/view/
- 3 http://d.hatena.ne.jp/faith_and_brave/
- 3 http://d.hatena.ne.jp/keyword/perl
- 3 http://k.hatena.ne.jp/keywordblog/D言語
- 3 http://pipes.yahoo.com/pipes/pipe.info?_id=vpw6npu13rgko15vbrnmsa
- 3 http://www.google.co.jp/reader/view/?hl=ja
- 3 http://www.google.co.jp/search?q=基礎文法最速マスター&ie=utf-8&oe=utf-8&aq=t&hl=ja&client=firefox-a&rlz=1R1GGLL_ja___JP362
- 3 http://www.google.co.jp/search?q=D言語+inout&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&client=firefox-a
