Чтобы избежать приведения и использовать статическую типизацию, вы можете либо вернуть кортеж (String, Int, Int)
:
def getResult = ("one two", 23, 45)
val res = getResult
res._1 // the line
// alternatively use the extractor
val (line, row, _) = getResult // col is discarded
line // the line
row // the row
, либо использовать класс регистра для результата:
case class MyResult(line: String, row: Int, col: Int)
def getResult = MyResult("one two", 23, 45)
val res = getResult
res.line // the line
// alternatively use the extractor provided by the case class
val MyResult(line, row, _) = getResult // col is discarded
line // the line
row // the row
Я бы предпочел класс case, потому что поля названы, а на самом деле это всего на одну строку больше.