mirror of
https://github.com/janet-lang/janet
synced 2025-08-29 17:08:03 +00:00
Clarify closure in loop test.
This commit is contained in:
@@ -203,9 +203,7 @@
|
||||
(assert (not= 0 1 1) "not= 2")
|
||||
|
||||
# Closure in while loop
|
||||
(def closures @[])
|
||||
(loop [i :range [0 5]]
|
||||
(array.push closures (fn [] i)))
|
||||
(def closures (for [i :range [0 5]] (fn [] i)))
|
||||
(assert (= 0 ((get closures 0))) "closure in loop 0")
|
||||
(assert (= 1 ((get closures 1))) "closure in loop 1")
|
||||
(assert (= 2 ((get closures 2))) "closure in loop 2")
|
||||
|
Reference in New Issue
Block a user