-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lazyZip to ArrayOps and StringOps #11063
Comments
A more generally applicable definition would be to put |
Context for |
The problem is that you would then be able to chain def example(xs: List[Int]): Unit = {
(xs lazyZip xs): LazyZip2[Int, Int, List[Int]]
// `LazyZipN` types are special lazy collection types
// We can go up to LazyZip4
(xs lazyZip xs lazyZip xs lazyZip xs): LazyZip4[Int, Int, Int, Int, List[Int]]
// After that, you get a compilation error
xs lazyZip xs lazyZip xs lazyZip xs lazyZip xs
// error: method lazyZip is not a member of LazyZip4
} However, note that there is an implicit conversion from (xs lazyZip xs lazyZip xs lazyZip xs lazyZip xs): LazyZip2[(Int, Int, Int, Int), Int, List[(Int, Int, Int, Int)]]
// We would get a LazyZip*2* instance instead of an expected LazyZip5 (which does not exist) In order to make it impossible to call |
Yes, that’s a good suggestion! |
- Also simplify the definition of lazyZip for collections. There is no need for extension methods and LazyZipOps. lazyZip can be defined as a regular method. - This alone makes it available for Array and String types but we want to get back an Array or String (if applicable) so we still need separate definitions in ArrayOps and StringOps. Fixes scala/bug#11063
The
lazyZip
operation is currently only available onIterable
. To use it on anArray
or aString
you have to first convert them to iterables. ThelazyZip
operation should be available onArray
andString
without requiring this conversion.The text was updated successfully, but these errors were encountered: