other stuff Flashcards
Curried function form
A ⇒ (B ⇒ C) = (A)(B) ⇒ C
Uncurried function form
(A,B) ⇒ C
First-class functions
treated like any other value
lazy val
computed once, when value is first used, reuses value afterwards
def
computed each time when value is used
val
computed once, when object is created, reuses value afterwards
closure
has free parameters ( which can be modified inside it)
generic classes
take types as a parameter
abstract
needs to be extended
Cannot instantiateabstract classes directly
Abstract methodsmust be implemented by subclasses
Supportspolymorphismand code reuse through inheritance
null
a subtype of any (+user defined) class
final
cannot be overridden or redefined in subclasses
No subclasses possible
super
use super keyword to call the immediate parent class’ method
any
Every class in a Scala execution environment inherits directly or indirectly from this class
Overloading
ability to redefine a function in more than one form, by defining two or more functions in a class sharing the same name
sum(a,b,c) <-> sum(a,b)
LUB
the lowest common ancestor
exists
x.exists(p)
a boolean indicating whether the predicate p holds for some element in x
forall
x.forall(p)
a boolean indicating whether the predicate p holds for all elements of x
count
x.count(p)
the number of elements in x that satisfy the predicate p