dChar Error

Salih Dincer salihdb at hotmail.com
Fri Dec 30 05:37:50 UTC 2022


On Friday, 30 December 2022 at 04:54:39 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> 
> So when you duplicated it, it was no longer in ROM, and 
> therefore writable.

There is no such thing as a ROM within a function.  Because str 
is a reference and slc is a local copy, right?  Have you tried 
running the code?  Okay, no string literals:

```d
void main()
{
   // example one:
   char[] str1 = "cur:€_".dup;
   str1.length.write(": "); // 8:
   str1[4..$].writefln!"[%s]"; // [€_]
     
   char[] slc1 = "$  _".dup;
   str1.replaceRight(slc1);
   str1.writefln!"[%s]"; // [cur:$  _]

   // example two:
   dchar[] str2 = cast(dchar[])"cur:€_"d;
   str2.length.write(": "); // 6:
   str2[4..$].writefln!"[%s]"; // [€_]
   
   dchar[] slc2 = cast(dchar[])"$ _"d;
   str2.replaceRight(slc2);
   str2.writefln!"[%s]";
}
```

SDB at 79


More information about the Digitalmars-d-learn mailing list