Why is partially applying functions on an implicit class giving me an error?

object RegexImplicits{
  implicit class RegexWrapper(r: scala.util.matching.Regex) {
    def matches(s: CharSequence): Boolean = r.pattern.matcher(s).find
  }

  def something(s:String):Boolean = s == "42"
}
import RegexImplicits._

//This errors with the message
//<console>:16: error: missing arguments for method matches in class RegexWrapper;
//follow this method with `_' if you want to treat it as a partially applied function
//              "a".r.matches _ 
"a".r.matches _ 

//But this works fine...
something _

Why does something _ work but the value involving the implicit class does not?

Does this have to do with the implicit class or is that a red herring and I'm experiencing a different problem?

Answers


It turns out as om-nom-nom pointed out, this is a known bug in the scala compiler.

http://issues.scala-lang.org/browse/SI-3218

Paulp's recommendations are to either use the dot free form or surround the _ with parentheses.

"a".r matches _

or

"a".r.matches(_)

Need Your Help

Python string split on possible None value

python django string split nonetype

I'm building a json and I want to split a comma seperated list ID's in array of ID's and put in the json. The problem is that the list can also be NULL in the database, thus None in python

consuming webservice in Jquery

c# jquery asp.net web-services

I used a Jquery truncator solution which is neatly written by Henrik Nyh to have a read more/less functionality. The script here

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.