정적 타이핑의 주조 및 혜택을 방지하기 위해, 당신은 튜플 (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
나는 것 필드 이름이 지정되고 실제로는 한 줄만 더 많기 때문에 사례 클래스를 선호합니다.