Timeline for Loop + Take for repeatedly taking elements from the same collection
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 4, 2017 at 17:54 | comment | added | Bobson |
Why not just name it position or pos instead of startPosition ? In XML comments you can explain that the starting position should be passed, but it's reasonably explicit enough even without that. And then the name is accurate the whole way through.
|
|
Dec 4, 2017 at 15:01 | comment | added | Flater |
@t3chb0t: Keep in mind you'd need to change the parameter to T[] values for that optimization. But I think this is getting to a point of a style distinction, rather than a meaningful code optimization :) I favor IEnumerable as a parameter because I really dislike manually casting things; but you might prefer more direct control :)
|
|
Dec 4, 2017 at 14:58 | vote | accept | t3chb0t | ||
Dec 4, 2017 at 14:58 | comment | added | t3chb0t |
This is clever and it made me think of one more scenario... it's not longer lazy because it dumps the source. I didn't think of it before... or maybe subconciously ;-] I think it'd better to use .ToArray().Loop() in this way rather than inside the extension and keep it lazy and consistant with other extensions. But I admit, it's not easy to pick one as there are good points for either approach.
|
|
Dec 4, 2017 at 14:50 | history | edited | Flater | CC BY-SA 3.0 |
added 1166 characters in body
|
Dec 4, 2017 at 14:45 | comment | added | Flater | @t3chb0t: Such is the life of a programmer ;) I also updated the answer to reflect what I think is a more pertinent optimization (the one for which I first needed to understand the problem you were trying to fix) | |
Dec 4, 2017 at 14:44 | history | edited | Flater | CC BY-SA 3.0 |
added 1166 characters in body
|
Dec 4, 2017 at 12:34 | history | edited | Flater | CC BY-SA 3.0 |
added 98 characters in body
|
Dec 4, 2017 at 12:32 | history | edited | t3chb0t | CC BY-SA 3.0 |
quoted OP's code
|
Dec 4, 2017 at 12:31 | comment | added | t3chb0t | Oooh, crap, now this seems to be so obvious ;-) | |
Dec 4, 2017 at 12:29 | history | answered | Flater | CC BY-SA 3.0 |