Skip to content
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

Option zipWithIndex should return an Option #8391

Closed
scabug opened this issue Mar 11, 2014 · 3 comments
Closed

Option zipWithIndex should return an Option #8391

scabug opened this issue Mar 11, 2014 · 3 comments

Comments

@scabug
Copy link

scabug commented Mar 11, 2014

zipWithIndex (just like map) should return an Option.

This is what I expected:
val x = Some("asdf")
val y: Option[(String, Int)] = x.zipWithIndex

This is what I got:
val x = Some("asdf")
val y: Iterable[(String, Int)] = x.zipWithIndex

The docs also state this:
zipWithIndex: Option[(A, Int)]

@scabug
Copy link
Author

scabug commented Mar 11, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8391?orig=1
Reporter: scalauserxxi (xiu)
Affected Versions: 2.10.3

@scabug
Copy link
Author

scabug commented Jan 30, 2015

@Ichoran said:
This is a consequence of the implicit conversion from Option to a collection. Zipping with an index is a pretty non-Option-like thing to do (it's equivalent to x.map(y => (y,0))), so it's not a bug that it isn't on Option itself. Whether the implicit conversion itself is wise is another issue, but for this issue things are working as intended.

@scabug scabug closed this as completed Jan 30, 2015
@scabug
Copy link
Author

scabug commented Oct 13, 2016

@SethTisue said:
The ticket on the Scaladoc being wrong here is #8394.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant