Tuples can contain different type of elements.
val pair = (99, "Luftballons")
println(pair._1)
println(pair._2)
apply method always retuns the same type, but each element of a tuple may be a different type: _1 can have one result type, _2 another, and so on.
These _N numbers are one-based, instead of zero-base, because string with 1 is a tradition set by other lanaguages with statically typed tuples, such as Haskell and ML.
댓글 없음:
댓글 쓰기