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.
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
w
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:
```d
string s = a.dup; // copy to heap, assuming
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:
```d
string s = a.dup; // copy to heap, assuming you need the data
to escape (use a[] otherwise)
s.writeln();
```
On Friday, 16 August 2024 at 15:58:31 UTC, Nick Treleaven 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:
```d
string s = a.dup; // copy to heap, assuming y
On Friday, August 16, 2024 10:37:45 AM MDT Nick Treleaven via Digitalmars-d-
learn wrote:
> On Friday, 16 August 2024 at 16:30:09 UTC, Jonathan M Davis wrote:
> > Whether the result of dup is then able to be implicitly
> > converted to immutable based on whether the operation is pure
> > depends on
On Friday, 16 August 2024 at 16:30:09 UTC, Jonathan M Davis wrote:
Well, you if you use dup, you're asking for a mutable array,
whereas if you use idup, you're asking for an immutable array.
Yes, `idup` may be needed e.g. for overloads varying on
mutability.
Whether the result of dup is then
On Friday, August 16, 2024 9:58:31 AM MDT Nick Treleaven via Digitalmars-d-
learn 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:
> >> ```d
> >> stri
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:
```d
string s = a.dup; // copy to heap, assuming you need the data
to escape (use a[] otherwise)
s.writeln();
```
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:
```d
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.
On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:
Is there an easy way to create a 60 character string in D?
Like in Python...
ul = '-'*60
2 ways:
```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[] othe
On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:
Is there an easy way to create a 60 character string in D?
Like in Python...
ul = '-'*60
You can use the repeat() function in std.range to create a range
of N consecutive elements.
If you need to assign this range to a string, you'll have
12 matches
Mail list logo