thp-lang.org/md/learn/classes/magic.md

25 lines
262 B
Markdown
Raw Normal View History

2023-10-05 12:56:34 +00:00
# Magic methods
2023-10-24 01:39:34 +00:00
Don't get special treatment.
2023-10-05 12:56:34 +00:00
```thp
class Cat
{
pub fun __sleep() -> Array[String]
{
// logic
}
}
```
2023-10-24 01:39:34 +00:00
```thp
2024-02-20 10:17:21 +00:00
val option = Some("GAAA")
val Some(value) = option
2023-10-24 01:39:34 +00:00
2024-02-20 10:17:21 +00:00
val colors = Array("red", "green", "blue")
val Array()
2023-10-24 01:39:34 +00:00
```