lang: core: Simplify list and map lookup default functions
This commit is contained in:
22
examples/lang/lookup_default.mcl
Normal file
22
examples/lang/lookup_default.mcl
Normal file
@@ -0,0 +1,22 @@
|
||||
import "fmt"
|
||||
|
||||
$some_list = ["l", "m", "n",]
|
||||
|
||||
$some_map = {
|
||||
"ottawa" => 6,
|
||||
"toronto" => 7,
|
||||
"montreal" => 8,
|
||||
"vancouver" => 9,
|
||||
}
|
||||
|
||||
print "letter" {
|
||||
msg => fmt.printf("letter: %s", $some_list[13] || "j"),
|
||||
|
||||
Meta:autogroup => false,
|
||||
}
|
||||
|
||||
print "city" {
|
||||
msg => fmt.printf("city: %d", $some_map["montréal"] || 13),
|
||||
|
||||
Meta:autogroup => false,
|
||||
}
|
||||
Reference in New Issue
Block a user