Lecture - Imperative Programming TT23, VIII
- Mutable and immutable collections
-
scala.collection.mutable
vsscala.collection.immutable
- Lists share the same static type but the dynamic type can be different
-
- GUI programming
-
scala-swing
- Layout
- Events
- Drawing
- Threads
-
Example code
import scala.swing.
object FirstSwingApp extends SimpleSwingApplication {
def top = new MainFrame {
contents = new Label("Hello world")
}
}
-
MainFrame
is a subclass ofFrame
which quits the application when done (e.g. the cross is clicked). - In match expressions,
case Blah
which try and match a specific value or type calledBlah
, butcase blah
means anything will bind toblah
. Can fix by doing
case `blah`
Flashcards
Can you explain the difference between
case Blah
case blah
case `blah`
in Scala?
case Blah
case blah
case `blah`
case Blah // Matches a specific type or value named Blah,
case blah // Will bind anything to a variable called "blah",
case `blah` // Matches a specific type or value named blah.