2016-05-31 13 views
1

なぜこのエラーがありますか?スカラーセット、オーバーロードされた定義へのあいまいな参照

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

ヴァル・果物=セット( "アプリ"、 "B"、 "C")

フルーツフィルタ(_.startsWith == "AP")

答えて

6

あなたは、使用しようとしています構文が正しくありません。 startsWith Stringのメソッドは、stringを引数として受け入れ、ブール値を返します。正しい使用法は次のとおりです。

fruit filter (_.startsWith("ap")) 
関連する問題