create fixed length string of characters
Bruce
bruce at technisolve.co.za
Sat Aug 17 06:03:09 UTC 2024
On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven wrote:
> ```d
> // use a fixed array:
> immutable char[60] a = '-';
> string s = a.dup; // copy to heap, assuming you need the data
> to escape (use a[] otherwise)
> s.writeln();
>
This seems to work without having to make a string dup. I just
wanted to
write a separator line in my output. Is there anything wrong
with using
the char[60] directly?
import std.stdio;
immutable char[60] a = '-';
void main() {
a.writeln();
}
More information about the Digitalmars-d-learn
mailing list