We have Optionwhich is Iterableover 0 or 1 elements.
I would like to have such a thing with two elements. The best I have:
Array(foo, bar).map{...}although I would like to:
(foo, bar).map{...}
(such that Scala recognizes that Iterablethere are two elements in).
Does such a design exist in the standard library?
EDIT: another solution is to create a method map:
def map(a:Foo) = {...}
val (mappedFoo, mappedBar) = (map(foo), map(bar))
source
share