I am learning Scala Higher Order Functions. I am studying an example that is a class; there is one method that receives a function and a value parameter and returns a value. The function is p: Tweet => Boolean
and the method implementation is further below. I want to know where is the implementation of the p function.
class NonEmpty(elem: Tweet, left: TweetSet, right: TweetSet) extends TweetSet {
def filterAcc(p: Tweet => Boolean, acc: TweetSet): TweetSet = {
if (p(elem)) {
left.filterAcc(p, acc.incl(elem))
right.filterAcc(p, acc.incl(elem))
} else {
left.filterAcc(p, acc)
right.filterAcc(p, acc)
}
}
acc
parameter?". It is whatever is passed asacc
whenfilterAcc
is called. Same forp
. – Didier Dupont