mirror of
https://github.com/janet-lang/janet
synced 2025-10-18 01:07:40 +00:00
Add early returns via break.
Inside a while loop, the argument to break does nothing as while loops always return nil.
This commit is contained in:
@@ -74,4 +74,10 @@
|
||||
|
||||
(assert (= nil ((fn [] (break) 4))) "break 2")
|
||||
|
||||
# Break with value
|
||||
|
||||
# Shouldn't error out
|
||||
(assert-no-error "break 3" (for i 0 10 (if (> i 8) (break i))))
|
||||
(assert-no-error "break 4" ((fn [i] (if (> i 8) (break i))) 100))
|
||||
|
||||
(end-suite)
|
||||
|
Reference in New Issue
Block a user