Reputation: 135
In the following Parser definition
def rep[T](p: => Parser[T]): Parser[List[T]]
I see the argument is a function. There is no type after p:
, so what is it's type?
Thanks
Basu
Upvotes: 1
Views: 332
Reputation: 11237
Someone correct me if I'm wrong here, but I believe with by-name parameters the type is the return type, in this case, Parser[T]
Basically what you see (return type) is what you pass into it
Upvotes: 1
Reputation: 1214
p
is actually not a function. An unpreceded =>
in the type description means that the argument is passed by name. Basically, it is not evaluated until it is used in the method, and it is evaluated every time that it is used in the method. Please see my answer here for a bit more info.
Upvotes: 4