编辑:现在只考虑ArrayDeque.(我原本以为LinkedList也不会覆盖这两种方法.)
集合类型ArrayDeque只使用它从Object继承的hashCode和equals方法实现.
为什么不用正确的实现覆盖这些方法(即基于包含的元素的哈希和相等测试)?
在scala中是否有语法或方法来访问case语句中的整个匹配结构?
为了澄清,如果有"as"关键字,可以这样做:
x match {
case Y(z) as matched =>
// do stuff both with "matched" and "z" here ...
...
}
Run Code Online (Sandbox Code Playgroud)