String "dequote" in phobos?

Imperatorn johan_forsberg_86 at hotmail.com
Thu May 13 21:57:51 UTC 2021


On Thursday, 13 May 2021 at 17:13:40 UTC, kdevel wrote:
> On Thursday, 13 May 2021 at 16:40:29 UTC, Imperatorn wrote:
>> Wouldn't this just this do that? 🤔
>>
>> ```d
>> string dequote(string s)
>> {
>>     return s[1..$-1];
>> }
>> ```
>
> 1. Your code throws Range errors if s.length < 2.
> 2. assert(dequote(`"fo\"o"`) == `fo"o`) fails
> 3. dequote(`"fo"o"`) does not throw.

WI spent 2 seconds thinking about it and 18 seconds typing on my 
phone so I'm not so surprised it didn't work. It did "Ok" for a 
20 sec attempt tho 😁


More information about the Digitalmars-d-learn mailing list