apfl/src/functional-tests/chained-assignments.at

63 lines
568 B
Text
Raw Normal View History

2022-11-19 20:27:08 +00:00
===== script =====
# Simple chained assignment
a = b = "foo"
print a
print b
print ""
# Check return value of chained assignment. Also does local assignment `:=` work?
print ({
a = b := "bar"
})
print a
print b
print ""
# Throw a list matching in there
l = [x y] = [1 2]
print l
print x
print y
print ""
# Same as first two tests, but force using the matcher mechanism
[a] = [b] = ["foo"]
print a
print b
print ""
print ({
[a] = [b] := ["bar"]
})
print a
print b
===== output =====
foo
foo
bar
bar
foo
[
1
2
]
1
2
foo
foo
[
"bar"
]
bar
foo