reflective calls in #scala:
trait A {
def add(a: Int, b: Int): Int = a + b
...
}
trait B {
def add(a: Int, b: Int): Int = a + b
...
}
def addOne(t: {def add(a: Int, b: Int): Int}, a: Int): Int =
t.add(a, 1)
addOne(new A{}, 3)
addOne(new B{}, 3)
I think the point is that it's reflection, but not a reflective call. A cast doesn't count.
-
-
I’m not talking about a cast though. Finding the right unapply method is not a cast. Dynamically applying it to the input is not a cast. I’m open to the idea that none of this happens, but I think it does
-
This Tweet is unavailable.
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.