FileMode.Out

私はなんどか苦しめられたんですけど、かれこれ一年の間ほどの間で一度も指摘されていない気がする。考えられるのは、

  • 全く問題ない
  • どこかで指摘されているがアホの私は気付いてない
  • 誰もこの問題に遭遇してない

どうでもいいや。

import std.stream;

int main() {
    File f1 = new File("out", FileMode.Out);
    f1.writeLine(`hello world`);
    f1.close();

    File f2 = new File("out", FileMode.Out);
    f2.writeLine(`hello`);
    f2.close();

    return 0;
}

out を見ると、 Linux では、

hello
world

Windows だと、

hello
orld

まあ、 LF と CRLF の違いはどうでも良いのだけど。

こっちなら truncate してくれる。

import std.file;

int main() {
    write("out", "hello world\n");
    write("out", "hello\n");
    return 0;
}
なにかあれば下記メールアドレスへ。
shinichiro.hamaji _at_ gmail.com
shinichiro.h