Using tupled
, as @Tomasz mentions, is a good approach.
You could also extract the tuple returned from foo
during assignment:
val (x, y) = foo(5)
bar(x, y)
This has the benefit of cleaner code (no _1
and _2
), and lets you assign descriptive names for x
and y
, making your code easier to read.