Something went wrong. Try again.
The Mesa programming language
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106import Core.Behaviors.Hash
dict := {"id": 105}#> {"id": 105}$print(dict)
dict["name"] := "Alice"#> Alice$print(dict["name"])
#> 2$print(dict.size)
#> Alice$print(dict.access("name"))dict.store("status", "active")#> active$print(dict.access("status"))
dict["note"] := nil#> nil$print(dict["note"])#> 4$print(dict.size)
#> 105each key in dict do when key == "id" then $print(dict[key]) endend
dict := {}dict["self"] := dict#> {"self": ...}$print(dict)
type Task(priority) impl Hash
def hash (0).hash endend
collisions := {}collisions[Task(1)] := "first"collisions[Task(2)] := "second"collisions[Task(1)] := "updated"#> updated$print(collisions[Task(1)])#> second$print(collisions[Task(2)])#> 1#> 2each task in collisions do $print(task.priority)end
literal := {Task(1): "first", Task(2): "second", Task(1): "updated"}#> {Task(priority: 1): "updated", Task(priority: 2): "second"}$print(literal)
#---
#! runtime error: key "b" not found
$print({"a": 1}["b"])
#---
#! runtime error: type Dict is not appendable
{"id": 105} << "name"
#---
#! runtime error: type List is not hashable
dict := {}dict[[1]] := 1
#---
#! runtime error: type Dict is not hashable
key := {}{key: 1}
#---
#! runtime error: type Task is not hashable
type Task(priority) end
{}[Task(1)]
#---
type Task(priority) end
dict := {}dict[Task] := 1#> 1$print(dict[Task])