I've created a class that can be parameterised by anything that can be converted to Numeric
class Complex[T <% Numeric[T]] (val real : T, val imag : T) {
//... complex number methods ...
}
Then elsewhere in the code I try:
var myComplex = new Complex(0, 1)
This raises a compilation error because (surprisingly) there's no implici...
I'm trying to integrate a Lift application into some existing Java code. In one of my snippets, I have an Array of Java objects that I need to map that into a NodeSeq. I can get an Array of Node's, but not a NodeSeq. (At least, not in very functional-looking way).
import scala.xml.NodeSeq
// pretend this is code I can't do anything ...
This is something I've wondered about for a while. I see this pattern a lot:
if (pf.isDefinedAt(in)) pf(in)
By breaking this up into two separate calls, all of the patterns that were evaluated in #isDefinedAt are then also evaluated in #apply. For example:
object Ex1 {
def unapply(in: Int) : Option[String] = {
println("Ex1")
...