我如何将模式匹配应用于此代码?所以它看起来像用函数式编写的代码:
def getIndex(i: Int): Option[Int] = {
if (check0(i) == Some) {
check0(i)
}
else if (check1(i) == Some) {
check1(i)
}
else if (check2(i) == Some) {
check2(i)
}
else if (check3(i) == Some) {
check3(i)
}
else {
None
}
}
方法check0, check1, check2, check3
全部返回Option[Int]