0
튜플이 스칼라에서 불변이라는 사실을 알고 있습니다. 따라서 패턴 일치를 사용하여 튜플을 변경합니다. 두 개의 3 튜플 요소가있는 2 개의 튜플이 있는데 각 요소는 시퀀스입니다. 내 문제는 : '첫 번째 튜플의 첫 번째 요소가 빈 시퀀스 인 경우 일부 기본값을 보냅니다.'스칼라 : 튜플에서 패턴 매칭
val (fooTuple, barTuple) =
{
// function that returns a 2-tuple with elements that are 3-tuples
((a, b, c), (d, e, f)) //Each of these is a sequence
} match {
case ((Seq(), x, y), z) => ((Seq("default"), x, y), z)
}
그것은 내가 잘못 뭐하는 거지 ((a, b, c), (d, e, f))
의 값을 인쇄시 MatchError
발생 : 내 코드는 다음과 같이 보입니다? 다른 모든 경우가 case other => other
val (fooTuple, barTuple) =
{
// function that returns a 2-tuple with elements that are 3-tuples
((a, b, c), (d, e, f)) //Each of these is a sequence
} match {
case ((Seq(), x, y), z) => ((Seq("default"), x, y), z)
case other => other
}
을 :