The version of readln you are using is[0]. This works by taking in a buffer of memory to write out, and returns how many codepoints were stored.

Because you are not reusing memory, not using this form you can of course use string[1] instead, rather than ``char[]``.

```d
string s = readln();
```

The definition of string is[2]:

```d
alias string  = immutable(char)[];
```

Note the immutable there, which means that each value in the slice cannot be modified. Hence why it can't be used as a buffer.

[0] https://dlang.org/phobos/std_stdio.html#.readln.2
[1] https://dlang.org/phobos/std_stdio.html#.readln
[2] https://github.com/dlang/dmd/blob/master/druntime/src/object.d#L69

Reply via email to