Gitiles
Code Review
Sign In
review.gerrithub.io
/
BiyuHuang
/
scala-for-the-Impatient
/
424f130999646d9a3d067b05e2f1f386c614278f
/
.
/
src
/
Chapter17
/
exercise02.scala
blob: 35435a7b6536cc35aa3b4b9c184734468695c581 [
file
] [
log
] [
blame
]
/**
* 定义一个可变类Pair[T],带一个swap方法,交换对偶中组件的位置。
*/
class
Pair
[
T
]
(
var
s
:
T
,
var
t
:
T
)
{
def
swap
()
=
{
val
temp
=
s
this
.
s
=
t
this
.
t
=
temp
}
override
def
toString
=
s
"s: $s, t: $t"
}