diff --git a/examples/learnxiny.tm b/examples/learnxiny.tm index 5315b03..a00776b 100644 --- a/examples/learnxiny.tm +++ b/examples/learnxiny.tm @@ -104,13 +104,13 @@ func main(): stop x # Tables are efficient hash maps - table := {"one": 1, "two": 2} + table := {"one"=1, "two"=2} >> table["two"] = 2 : Int? # The value returned is optional because none will be returned if the key # is not in the table: - >> table["xxx"]! + >> table["xxx"] = none : Int? # Optional values can be converted to regular values using `!` (which will @@ -123,7 +123,7 @@ func main(): = 0 : Int # Empty tables require specifying the key and value types: - empty_table := {:Text:Int} + empty_table := {:Text,Int} # Tables can be iterated over either by key or key,value: for key in table: @@ -141,22 +141,22 @@ func main(): # Tables can have a fallback table that's used as a fallback when the key # isn't found in the table itself: - table2 := {"three": 3; fallback=table} + table2 := {"three"=3; fallback=table} >> table2["two"]! = 2 >> table2["three"]! = 3 # Tables can also be created with comprehension loops: - >> {x:10*x for x in 5} - = {1:10, 2:20, 3:30, 4:40, 5:50} + >> {x=10*x for x in 5} + = {1=10, 2=20, 3=30, 4=40, 5=50} # If no default is provided and a missing key is looked up, the program # will print an error message and halt. # Any types can be used in tables, for example, a table mapping arrays to # strings: - table3 := {[10, 20]: "one", [30, 40, 50]: "two"} + table3 := {[10, 20]="one", [30, 40, 50]="two"} >> table3[[10, 20]]! = "one" @@ -243,7 +243,7 @@ func takes_many_types( floating_point_number:Num, text_aka_string:Text, array_of_ints:[Int], - table_of_text_to_bools:{Text:Bool}, + table_of_text_to_bools:{Text,Bool}, pointer_to_mutable_array_of_ints:@[Int], optional_int:Int?, function_from_int_to_text:func(x:Int -> Text), @@ -293,7 +293,7 @@ func demo_structs(): >> "$alice" == 'Person(name="Alice", age=30)' = yes - table := {alice: "first", bob: "second"} + table := {alice="first", bob="second"} >> table[alice]! = "first" @@ -338,8 +338,8 @@ func demo_enums(): >> "$my_shape" == "Shape.Circle(1)" = yes - >> {my_shape:"nice"} - = {Shape.Circle(1):"nice"} + >> {my_shape="nice"} + = {Shape.Circle(1)="nice"} func demo_lambdas(): # Lambdas, or anonymous functions, can be used like this: