aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/game/game.tm2
-rw-r--r--examples/ini/ini.tm8
-rw-r--r--examples/learnxiny.tm5
-rw-r--r--examples/tomodeps/tomodeps.tm4
-rw-r--r--examples/wrap/wrap.tm2
5 files changed, 10 insertions, 11 deletions
diff --git a/examples/game/game.tm b/examples/game/game.tm
index 8c5124d0..c7d843e3 100644
--- a/examples/game/game.tm
+++ b/examples/game/game.tm
@@ -9,7 +9,7 @@ func main(map=(./map.txt)):
extern InitWindow:func(w:Int32, h:Int32, title:CString)->Void
InitWindow(1600, 900, "raylib [core] example - 2d camera")
- map_contents := map:read():or_exit("Could not find the game map: $map")
+ map_contents := map:read() or exit("Could not find the game map: $map")
World.CURRENT:load_map(map_contents)
diff --git a/examples/ini/ini.tm b/examples/ini/ini.tm
index 8b91d3fa..37692cae 100644
--- a/examples/ini/ini.tm
+++ b/examples/ini/ini.tm
@@ -7,7 +7,7 @@ _HELP := "
"
func parse_ini(path:Path)->{Text:{Text:Text}}:
- text := path:read():or_exit("Could not read INI file: $\[31;1]$(path.text_content)$\[]")
+ text := path:read() or exit("Could not read INI file: $\[31;1]$(path.text_content)$\[]")
sections := {:Text:@{Text:Text}}
current_section := @{:Text:Text}
@@ -29,7 +29,7 @@ func parse_ini(path:Path)->{Text:{Text:Text}}:
return {k:v[] for k,v in sections}
func main(path:Path, key:Text?):
- keys := key:or_else(""):split($|/|)
+ keys := (key or ""):split($|/|)
if keys.length > 2:
exit("
Too many arguments!
@@ -42,7 +42,7 @@ func main(path:Path, key:Text?):
return
section := keys[1]:lower()
- section_data := data:get(section):or_exit("
+ section_data := data:get(section) or exit("
Invalid section name: $\[31;1]$section$\[]
Valid names: $\[1]$(", ":join([k:quoted() for k in data.keys]))$\[]
")
@@ -51,7 +51,7 @@ func main(path:Path, key:Text?):
return
section_key := keys[2]:lower()
- value := section_data:get(section_key):or_exit("
+ value := section_data:get(section_key) or exit("
Invalid key: $\[31;1]$section_key$\[]
Valid keys: $\[1]$(", ":join([s:quoted() for s in section_data.keys]))$\[]
")
diff --git a/examples/learnxiny.tm b/examples/learnxiny.tm
index 7feca6c1..f003167f 100644
--- a/examples/learnxiny.tm
+++ b/examples/learnxiny.tm
@@ -110,12 +110,11 @@ func main():
# The value returned is optional (because the key might not be in the table).
# Optional values can be converted to regular values using `!` (which will
- # create a runtime error if the value is null) or :or_else() which uses a
- # fallback value if it's null.
+ # create a runtime error if the value is null) or the `or` operator:
>> table:get("two")!
= 2
- >> table:get("xxx"):or_else(0)
+ >> table:get("xxx") or 0
= 0
# Empty tables require specifying the key and value types:
diff --git a/examples/tomodeps/tomodeps.tm b/examples/tomodeps/tomodeps.tm
index b2dc82dc..1cd2ee59 100644
--- a/examples/tomodeps/tomodeps.tm
+++ b/examples/tomodeps/tomodeps.tm
@@ -80,7 +80,7 @@ func _draw_tree(dep:Dependency, dependencies:{Dependency:{Dependency}}, already_
child_prefix := prefix ++ (if is_last: " " else: "│ ")
- children := dependencies:get(dep):or_else({:Dependency})
+ children := dependencies:get(dep) or {:Dependency}
for i,child in children.items:
is_child_last := (i == children.length)
_draw_tree(child, dependencies, already_printed, child_prefix, is_child_last)
@@ -89,7 +89,7 @@ func draw_tree(dep:Dependency, dependencies:{Dependency:{Dependency}}):
printed := {:Dependency}
say(_printable_name(dep))
printed:add(dep)
- deps := dependencies:get(dep):or_else({:Dependency})
+ deps := dependencies:get(dep) or {:Dependency}
for i,child in deps.items:
is_child_last := (i == deps.length)
_draw_tree(child, dependencies, already_printed=&printed, is_last=is_child_last)
diff --git a/examples/wrap/wrap.tm b/examples/wrap/wrap.tm
index 54198193..a89d8b41 100644
--- a/examples/wrap/wrap.tm
+++ b/examples/wrap/wrap.tm
@@ -82,7 +82,7 @@ func main(files:[Path], width=80, inplace=no, min_split=3, rewrap=yes, hyphen=UN
files = [(/dev/stdin)]
for file in files:
- text := file:read():or_exit("Could not read file: $(file.text_content)")
+ text := file:read() or exit("Could not read file: $(file.text_content)")
if rewrap:
text = unwrap(text)