# Lecture - Imperative Programming TT23, VIII

> Source: https://ollybritton.com/notes/uni/prelims/tt23/ip/lectures/viii/ · Updated: 2023-05-12 · Tags: uni, lecture

- Mutable and immutable collections
	- `scala.collection.mutable` vs `scala.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

```scala
import scala.swing.

object FirstSwingApp extends SimpleSwingApplication {
	def top = new MainFrame {
		contents = new Label("Hello world")
	}
}
```

- `MainFrame` is a subclass of `Frame` 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 called `Blah`, but `case blah` means anything will bind to `blah`. Can fix by doing

```
case `blah`
```

### Flashcards
Can you explain the difference between
```scala
case Blah
case blah
case `blah`
```
in Scala?::
```scala
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.
```

---
Olly Britton — https://ollybritton.com. Machine-readable index: https://ollybritton.com/llms.txt
