2016-05-31 16 views
1

Warum habe ich diesen Fehler?Scala Set, mehrdeutige Referenz zu überladene Definition

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 Obst = Set ("App", "b", "c")

Fruchtfilter (_.startsWith == "ap")

Antwort

6

Sie versuchen, zu verwenden, falsche Syntax StartsWith-Methode von String akzeptiert Zeichenfolge als Argument und gibt Boolean zurück. Die korrekte Verwendung ist also:

fruit filter (_.startsWith("ap")) 
Verwandte Themen