Question

In Haskell you can write:

x :: (Int,Int) -> Int
x (p,s) = p

In Scala you would write:

def x(a: (Int, Int)) = a._1

or:

def x(a: (Int, Int)) = a match {
    case (p, s) => p
}

Why not have something like

def x(_: (p: Int, s: Int)) = p

or

def x(foo: (p @ Int, s @ Int)) = p

?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top