4 ms·
> I don't want .Where() called on an array to return another array. I want a lazy IEnumerable<T> almost every time. Yes, good point. There is a lot of space
by harveywi 10y ago
> I don't want .Where() called on an array to return another array. I want a lazy IEnumerable<T> almost every time.
Yes, good point. There is a lot of space to explore in collections API designs, and the LINQ design is just one of them that makes its own tradeoffs (e.g., only have to implement "GetEnumerator()" to get a watered-down monadic experience). Contrast that with the well-meaning but convoluted and buggy Scala collections API (very difficult for novices to create a custom collection due to CanBuildFrom and other tricky stuff).
Paul Phillips came up with a pretty neat collections API [1, 2] that provides a nice feature set, including high-performance and typesafe views when you don't really want to wastefully create a temporary collection just to interact with the first 10 elements.
[1] http://www.slideshare.net/extempore/a-scala-corrections-library http://www.slideshare.net/extempore/a-scala-corrections-libr...
[2] https://www.youtube.com/watch?v=uiJycy6dFSQ https://www.youtube.com/watch?v=uiJycy6dFSQ