relative to the following scala code, the m2a and m2b functions apparently differ only in the case of the parameter, i.e. abc vs Abc. This, apparently, affects the result in accordance with the example below. When you run it with the compiler of the last 2.8, it leads to the following (I would expect that everything is correct). Any ideas would be appreciated.
m1=true m2a=true m2b=false m3=true
the code
package sample import scala.xml._ object ParamTest extends Application { def m1(n:Node, abc:String):Boolean = { n == <id>{Text(abc)}</id> } def m2a(n:Node, Abc:String):Boolean = n match { case <id>{Text(Abc)}</id> => true case _ => false; } // why does this one not work? def m2b(n:Node, abc:String):Boolean = n match { case <id>{Text(abc)}</id> => true case _ => false; } def m3(n:Node, abc:String):Boolean = n match { case Elem(_,"id",_,_, c @_ *) => { c contains Text(abc) } } def runner(n:Node, f:(Node, String)=>Boolean):Boolean = { f(n, "x") && !f(n, "y") && !f(n, ""); } val x = <id>x</id> println("m1="+runner(x, m1)); println("m2a="+runner(x, m2a)); println("m2b="+runner(x, m2b)); println("m3="+runner(x, m3)); }
source share