2016-05-31 3 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 메소드는 문자열을 인수로 받아들이고 부울을 반환합니다. 올바른 사용법은 다음과 같습니다.

fruit filter (_.startsWith("ap")) 
관련 문제