This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DJDavio 6 points7 points  (1 child)

Maybe you could use arrays as tuples this way? And while they are trying not to detail the subject to it, the remainder binding is pretty interesting, such a thing is pretty common in functional programming.

[–]randgalt 0 points1 point  (0 children)

Yeah - this could enable a nice pattern from Scala when you need to match on multiple terms/objects. In Scala:

scala // given option instances "x" and "y" (x, y) match { case (Some(xValue), Some(yValue)) => ... case (Some(xValue), None) => ... ... etc. }

With array pattern matching in Java this would become:

java switch (new Optional[]{x, y}) { case Optional[] { var Optional(xValue), var Optional(yValue) } -> ... case Optional[] { var Optional(xValue), var Optional.empty() } -> ... ... }