Reputation: 898
why do i have this error?
Error:(5, 18) ambiguous reference to overloaded definition, both method startsWith in class String of type (x$1: String)Boolean and method startsWith in class String of type (x$1: String, x$2: Int)Boolean match expected type ? fruit filter (_.startsWith == "ap")
val fruit = Set("app", "b", "c")
fruit filter (_.startsWith == "ap")
Upvotes: 1
Views: 283
Reputation: 8866
You're trying to use incorrect syntax. startsWith method of String accepts string as argument and returns boolean. So the correct usage is:
fruit filter (_.startsWith("ap"))
Upvotes: 8