Error: none of the overloads of template `once.main.each!((l)
Rene Zwanenburg
renezwanenburg at gmail.com
Wed Oct 4 09:48:36 UTC 2023
On Wednesday, 4 October 2023 at 08:11:12 UTC, Joel wrote:
> What am I missing?
Splitter returns a forward range so you can't slice the result.
You can use take() and drop() instead. Also, converting a string
range to int[] doesn't seem to work, but I don't know if it
should. Here is a version that works:
```D
import std;
void main() {
struct DateRem {
Date date;
string rem;
string toString() const => text(date.toSimpleString, " ",
rem);
}
DateRem[] daterem;
data
.splitter('\n')
.filter!(l => l.length && l[0].isDigit)
.each!((l) {
auto parts=l
.splitter
.take(3)
.map!(to!int)
.array;
if (parts.length==3) {
daterem~=DateRem(Date(parts[2],parts[1],parts[0]),
l.splitter.drop(3).join(" "));
}
});
daterem.each!writeln;
}
auto data="04 10 2023 17:28, not much
30 9 2023 21:08, very little";
```
More information about the Digitalmars-d-learn
mailing list