top | item 39499255

(no title)

JonasWanke | 2 years ago

Exactly, structs are also used as maps/dictionaries, and the current implementation of them in our VM is as hash maps. (We have optimizations planned for this.) You'd create a struct with tags (symbols) as keys to create a typical struct/class, and can use arbitrary keys if you want to use it as a more general map:

  # A struct with two tags as keys mapping to functions
  httpServerStruct = [GetNextRequest: { … }, Close: { … }]
  
  # A map with text keys
  capitalCitiesMap = ["Germany": "Berlin", "France": "Paris"]

discuss

order

No comments yet.