On Friday, 20 January 2023 at 03:11:33 UTC, Ruby The Roobster wrote:
Take this example:

```d
import std;
void main()
{
    auto c = "a|b|c|d|e".splitter('|');
    c.writeln;
    string[] e = ["a", "b", "c", "d", "e"];
    assert(c.equal(e));
    typeof(c).stringof.writeln;
}
```

The program prints:

["a", "b", "c", "d", "e"]
Result

What is the purpose of this 'Result' type? To serve as a generic range? Because, it seems to only cause problems. For example, you cannot assign or cast the result type into a range, even when the type has the same inherent function:

```d
string[] c = "a|b|c|d|e".splitter('|'); // fails
string[] d = cast(string[])"a|b|c|d|e".splitter('|'); // also fails
```

And if you need to perform a set operation?

```d
c[] ~= "lolno"; // fails, as [] isn't defined for Result.
```

Then what is the point of this type, if not to just make things difficult? It cannot be casted, and vector operations cannot be performed, and it seems to just serve as an unnecessary generalization.

Furthermore, it can also be confirmed that each member of c is a string, further solidifying my opinion of 'Result' as just being a generic range template, that cannot be casted to an array of the original type.

Reply via email to