mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
compiler: implement clear builtin for slices
This commit is contained in:
committed by
Ron Evans
parent
f791c821ff
commit
a2f886a67a
Vendored
+6
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
// The new min/max builtins.
|
||||
ia := 1
|
||||
ib := 5
|
||||
ic := -3
|
||||
@@ -9,4 +10,9 @@ func main() {
|
||||
fc := -3.0
|
||||
println("min/max:", min(ia, ib, ic), max(ia, ib, ic))
|
||||
println("min/max:", min(fa, fb, fc), max(fa, fb, fc))
|
||||
|
||||
// The clear builtin, for slices.
|
||||
s := []int{1, 2, 3, 4, 5}
|
||||
clear(s[:3])
|
||||
println("cleared s[:3]:", s[0], s[1], s[2], s[3], s[4])
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -1,2 +1,3 @@
|
||||
min/max: -3 5
|
||||
min/max: -3.000000e+000 +5.000000e+000
|
||||
cleared s[:3]: 0 0 0 4 5
|
||||
|
||||
Reference in New Issue
Block a user