On Tuesday, 11 June 2024 at 09:17:21 UTC, madwebness wrote:
While I do understand what you're saying, I'm not sure I understand how to fix the code.

With the following function definition what the function returns is correct and the problem is in the unittest code. Note that `writeln()` prints what's expected here program fails only when it gets to `assert()`:

```
auto sliceIt(string[] words_arr) {...};

unittest {
  auto words = ["HELLO", "world", "hi", "ENDOFTHERUNWAY"];
  auto resulting_arr = sliceIt(words);
  writeln(resulting_arr[0]); // => "world"
assert(resulting_arr[0] == "world"); // => ERROR mentioned in (3) in the previous post.
}
```
  • Comparing slice ... madwebness via Digitalmars-d-learn
    • Re: Compari... madwebness via Digitalmars-d-learn
      • Re: Com... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
        • Re:... madwebness via Digitalmars-d-learn
          • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... madwebness via Digitalmars-d-learn
            • ... madwebness via Digitalmars-d-learn
              • ... madwebness via Digitalmars-d-learn
                • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn

Reply via email to