toChars buffer access?
Steven Schveighoffer
schveiguy at gmail.com
Fri Jun 10 01:49:25 UTC 2022
On 6/9/22 8:18 PM, Salih Dincer wrote:
> auto test = result.to!char[];
I'm not sure if I got all your code, but just to note, the operator
precedence here means it's `(result.to!char)[]`
> The only solution is to use .array:
>
> assert(result.array == ['4', '1']);
Well, 2 things. First, you can compare a char[] to a string, so
`result.array == "41"` should be fine.
Second, you can't use == to compare ranges, you need to use
std.algorithm.equal:
```d
import std.algorithm : equal;
assert(equal(result, "41"));
```
(and yes, this should work for different character types, even though a
string is element type dchar).
Not sure if this helps, I feel like there was some code missing from
your example.
-Steve
More information about the Digitalmars-d
mailing list