Lecture - Imperative Programming TT23, VIII
- Mutable and immutable collections
-
scala.collection.mutablevsscala.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")
}
}
-
MainFrameis a subclass ofFramewhich quits the application when done (e.g. the cross is clicked). - In match expressions,
case Blahwhich try and match a specific value or type calledBlah, butcase blahmeans 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.