Thread overview
Can't pass data from filter to each
Apr 17, 2017
Suliman
Apr 17, 2017
Suliman
Apr 17, 2017
Stanislav Blinov
April 17, 2017
I am writing lambda function. I need filter data at first step and than do dome operation on them (for start simply print on the screen. I wrote next code:

MySQLTablesRange.filter!(a=>a[0].coerce!string.canFind("_")).each!(a => to!int(a[0].coerce!string.split("_")[1]).writeln);


But it's seem that each do not handle any data. I tested if data is corectly filtered and next code successfully print it's output.

auto t = MySQLTablesRange.array.filter!(a=>a[0].coerce!string.canFind("_"));
t.each!(a=>a[0].coerce!string.writeln);

But what is wrong with first code?
April 17, 2017
New question. Can I put result of filtering in itself without creation of new variables like x:

auto x = MySQLTablesRange.array.filter!(a=>a[0].coerce!string.canFind("_"));
April 17, 2017
On Monday, 17 April 2017 at 10:02:22 UTC, Suliman wrote:
> New question. Can I put result of filtering in itself without creation of new variables like x:
>
> auto x = MySQLTablesRange.array.filter!(a=>a[0].coerce!string.canFind("_"));

No. filter is simply a wrapper around the source range, it does not modify it.

As for the problems you are having with ranges seeming empty, they are all due to the fact that the ResultRange in mysql-native isn't designed to support such chaining of calls. It's probably best to first exhaust a ResultRange and put it into an array.