0
def f: (Int, Int) => (Int, Int) => List[Int] = {
  (x, y) => (a, b) => 
    //do anything
    if(y == 5)
      return List(a, x)
    // do something else
}

When I use this, Intellij says:

type mismatch;
found :List[Int]
required: (Int, Int) => (Int, Int) => List[Int]
return List(a,x)

If I do the same, without return (which wouldn't work, if there is code after it), there is no error. Why does the return need this type?

Cœur
  • 37,241
  • 25
  • 195
  • 267
no0by5
  • 632
  • 3
  • 8
  • 30

0 Answers0