kaxori
03/25/2025, 3:14 PMmap := {
"simple":"value",
"nested":
{
"A":1,
"B":2
}
}floitsch
03/25/2025, 3:17 PMis Map checkfloitsch
03/25/2025, 3:19 PMas or assign it to a typed local:
nested/Map := map["nested"]
or
(map["nested"] as Map)...kaxori
03/25/2025, 3:21 PMkaxori
03/25/2025, 3:40 PMfloitsch
03/25/2025, 3:49 PMfloitsch
03/25/2025, 3:49 PMfloitsch
03/25/2025, 3:50 PMis-interface methods to these classes.floitsch
03/25/2025, 3:50 PMfloitsch
03/25/2025, 3:51 PMfloitsch
03/25/2025, 3:51 PM3 << 1 == 6.floitsch
03/25/2025, 3:51 PMfloitsch
03/25/2025, 3:51 PM1.floitsch
03/25/2025, 3:52 PMis int starts by looking whether the "pointer" has 0 in the least-significant bit. If not, it also checks for the Integer class-id, which is used when values are bigger than 31 bits (since they wouldn't fit into words anymore).floitsch
03/25/2025, 3:53 PMtoit tools snapshot classes my-snapshot.floitsch
03/25/2025, 3:55 PMis should be in there.floitsch
03/25/2025, 3:55 PMkaxori
03/25/2025, 3:55 PMfloitsch
03/25/2025, 3:55 PMis not, as in if x is not Map)floitsch
03/25/2025, 3:55 PMkaxori
03/25/2025, 3:56 PMfloitsch
03/25/2025, 3:56 PMis and is not as operators in our parser.floitsch
03/25/2025, 3:56 PMkaxori
03/25/2025, 4:02 PMkaxori
03/25/2025, 4:22 PMm-a := { "A":1 }
m-b := { "B":2 }
m-composed := { m-a, m-b }
this way does not work. Is there a way to combine maps ?floitsch
03/25/2025, 4:23 PM{ m-a, m-b } is a set.floitsch
03/25/2025, 4:24 PM[m-a, m-b], or a map: {"m-a": m-a, "m-b", m-b}.
Toit doesn't have JavaScript's automatic "use the variable name as key".kaxori
03/25/2025, 4:29 PMm-composed := { m-a.first: m-a, m-b.first: m-b}kaxori
03/25/2025, 4:31 PMkaxori
03/25/2025, 5:06 PMm-composed := {:}
m-a.do: | k v | m-composed[k] = v
m-b.do: | k v | m-composed[k] = v
*... found another way *floitsch
03/25/2025, 5:07 PMkaxori
03/25/2025, 5:08 PMfloitsch
03/26/2025, 1:03 PMkaxori
03/26/2025, 1:38 PMmap-elements := { "A":1, "B":2, "C":3 }
map := {"key":"value"}
map["k"] = "v"
// to add elements to map
map-elements.do (: |k v| map[k] = v)
map["nested"] = {:} // create "nested" sub-map
(map["nested"])["k"] = "v" // add one k-v-element to sub-map
// / to add elements to sub-map
map-elements.do (: |k v| (map["nested"])[k] = v)
sub-map := map["nested"] // easier to read
sub-map["key"] = "value"
...
- 128 nesting levels supported !