2 ms·
You can improve on the matching example by adding the line: implicit def string2regexTest(s:String)=new RegexTest(s) //Now we can just do someStri
by Robin_Message 16y ago
You can improve on the matching example by adding the line:
implicit def string2regexTest(s:String)=new RegexTest(s)
//Now we can just do
someString @= /regularExpression/
which lets you use @= as you use ~= in Ruby.
This looks sort of evil à la monkey-patching, but it isn't nearly as bad as the compiler will complain if more than one implicit ever matches, which prevents the situation where something is redefined under you. This is definitely a good thing Scala has going for it that Ruby doesn't.