所以编译:
def compress[T](list: List[T]): List[(T, Int)] =
{
list.zipWithIndex.filter { tuple => (tuple._2 == 0) || (tuple._1 != list(tuple._2 - 1)) }
}
这不会编译:
def compress[T](list: List[T]): List[(T, Int)] =
{
list.zipWithIndex.filter { (_._2 == 0) || (_._1 != list(_._2 - 1)) }
}
为什么?