You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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.
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)]
The text was updated successfully, but these errors were encountered: