What an AI will try: return, break and continue
The complete source of forAI_no_break_continue_return.ek9, which fails to compile exactly as captioned. Shown on forAI.html.
Fails with E01072: 'return' does not exist in EK9 - declare return values with '<-' and compiler ensures all paths initialize; E01070: 'break' does not exist in EK9 - use stream pipelines with 'head' or guards; E01071: 'continue' does not exist in EK9 - use stream pipelines with 'filter' or 'skip'
#!ek9 defines module bad.site.forAI.nobreak defines constant skipped <- 50 defines function isMatch() as pure -> item as String <- rtn as Boolean: item? firstMatch() -> items as List of String <- found as String: String() for item in items if isMatch(item) return item // ❌ No 'return' break // ❌ No 'break' printAllBut() stdout <- Stdout() for i in 0 ... 100 if i == skipped continue // ❌ No 'continue' stdout.println($i)
Download forAI_no_break_continue_return.ek9 - it fails to compile on purpose, with the error its @Error line states.