This link has been bookmarked by 11 people . It was first bookmarked on 29 May 2008, by Christian Winkler.
-
20 Jul 10
-
Recall from previous articles that Scala treats functions as values, just as it does any other value in the language, like
Int,Float, orDouble. I can leverage that in this case by modeling myPersonto havedoSomethingnot as a method to be overridden in a derived class, but as a function value to be invoked, replaced, and extended. -
This is an extension of the "higher order functions" concept that functional programmers toss around.
-
In Scala, because the primary constructor appears on the class declaration, instead of as a "traditional" member of the class, passing parameters up to the base takes on a whole new dimension.
-
In Scala, primary constructor parameters are passed on the
classline, but you can also use thevalmodifier on these parameters in order to easily introduce accessors (and mutators, in the case ofvar) on the class itself. -
Scala doesn't differentiate fields from methods the way that the Java language does. This is actually a deliberate design decision that allows Scala programmers to "hide" the distinction between fields and methods quite easily from those who use the base class.
-
the base class from which all Scala classes inherit, including types like
Int,Float,Double, and the other numeric types, is thescala.Anytype, which defines a core set of methods available on any type in Scala:==,!=,equals,hashCode,toString,isInstanceOf, andasInstanceOf,
-
-
02 Apr 09
-
04 Sep 08
-
09 Jun 08
-
30 May 08
-
29 May 08
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.