Comparing slice to an Array in assert

madwebness madwebness at noreply.noreply
Tue Jun 11 09:51:55 UTC 2024


On Tuesday, 11 June 2024 at 09:48:36 UTC, madwebness wrote:
> On Tuesday, 11 June 2024 at 09:29:05 UTC, madwebness wrote:
>> My version that runs:
>
> Ran the code exactly as you posted. It works and I found the 
> issue. Apparently, if I add =* to the end of the last element, 
> the assertion fails with the error.
>
> ```
> auto words = ["HELLO", "world", "hi", "ENDOFTHERUNWAY=*"];
> ```
>
> results in:
> ```
> core.exception.AssertError at ./code.d(23): Assertion failure
> ----------------
> ??:? _d_assertp [0x360904]
> ??:? _Dmain [0x3073c3]
> ```
>
> I don't understand why, isn't it supposed to be treated as a 
> string?

Ah, my mistake. With the regular expression adjusted to 
`r"^[A-Z]+(=.*)?$"` it works just fine. Thank you very much for 
running the code for me. All very simple, I'm just new to the 
language.


More information about the Digitalmars-d-learn mailing list