scala结构类型

在 scala 中, 可以通过 type 关键字声明为 结构类型

1
type  = { def close():Unit }

这样当需要约束参数实现了 close 方法的时候, 只需要这样写:

1
def f(res:X) = res.close