Open GoogleCodeExporter opened 8 years ago
This is a known issue, current workaround requires you to move the loop body
into method with parameters, this will give you the behavior you want. I
haven't gotten around to create a generalized automatic solution for it.
Original comment by DanelK...@gmail.com
on 10 Oct 2013 at 11:50
Well, I think this is a pretty huge issue :) I know of a workaround.
Original comment by krunosla...@gmail.com
on 13 Oct 2013 at 10:11
You mean besides extracting the loop body into a new method?
Original comment by DanelK...@gmail.com
on 14 Oct 2013 at 4:54
Well extracting into a new method breaks the context of the loop. I've used
this.
foreach (PriceRange _priceRange in priceRanges)
{
Action _ = (priceRange) =>
{
...
elem.click((e) =>
{
console.log(priceRange);
});
};
_(_priceRange);
}
Original comment by krunosla...@gmail.com
on 14 Oct 2013 at 11:07
I see, that's cool, although I would usually simply create an extension ForEach
method, which gives out a bit cleaner syntax:
public static void ForEach<T>(this IJsArrayEnumerable<T> list, JsAction<T>
action)
{
//you know what goes here... :-)
}
In any case you're right about the issue, it's a known limitation, and should
be added as one and fixed.
Original comment by DanelK...@gmail.com
on 16 Oct 2013 at 9:44
Original issue reported on code.google.com by
krunosla...@gmail.com
on 29 Sep 2013 at 7:42