August 16

On Friday, 16 August 2024 at 18:00:25 UTC, Renato Athaydes wrote:

>

On Friday, 16 August 2024 at 13:30:53 UTC, IchorDev wrote:

>

On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven wrote:

>

On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:

string s = a.dup; // copy to heap, assuming you need the data to escape (use a[] otherwise)
s.writeln();

I think you meant idup? dup will make it mutable.

I found the docs of dup here: https://dlang.org/library/std/container/array/array.html

But not idup. Where does that come from?

Ah nevermind, I was looking at the container Array not the built-in array type, which is documented here: https://dlang.org/spec/arrays.html#array-properties which does mention idup!

August 17

On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven wrote:

>
// 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();
    }
August 17

On Saturday, 17 August 2024 at 06:03:09 UTC, Bruce wrote:
Is there anything wrong

>

with using
the char[60] directly?

In this case it’s fine to.

1 2
Next ›   Last »