I am new to Scala and to funcprog.
I have a piece of code (some of you might recognize it):
trait SwingApi {
type ValueChanged <: Event
val ValueChanged: {
def unapply(x: Event): Option[TextField]
}
...
}
where I do not underestand what val ValueChanged: {...} is.
From this post I sort of learned that
type ValueChanged <: Event
and
val ValueChanged: {
def unapply(x: Event): Option[TextField]
}
are two unrelated things because they are in different namespaces, etc, and type ValueChanged is an abstract subtype of Event.
Good, then I try in a Scala worksheet:
type myString <: String
val myString: {
def myfunc(x: String): String
}
and it shows me an error "only classes can have declared and undefined members"... Isn't it a similar construction?
Finally, the questions are:
what is ValueChanged in val ValueChanged part of code?
is it truely so unrelated to type ValueChanged <: Event
what does this syntax mean:
val myVal:{def func{x:T}:T}
? What's the name of the value, its type and its actual value here?
Thanks!