1
votes

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")

1

1 Answers

8
votes

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"))