1
我甚至不確定這是關於關閉,但我不能在以下代碼中推斷e
。理解scala中的閉包?
type Set = Int => Boolean
/* characteristic function of Set */
def contains(s: Set, elem: Int): Boolean = s(elem)
/* definition of a singleton set, returning a set of only one given element */
def singletonSet(elem: Int): Set = e => e == elem
在上面的代碼中,e
從哪裏來?我該如何推理?