yield
without the do
=> (defn foo [n]
... (if (< n 10) (yield n)))
Traceback (most recent call last):
File "/Users/joehakimrahme/.venv/hy/lib/python2.7/site-packages/hy/importer.py", line 45, in ast_compile
return compile(ast, filename, mode, __future__.CO_FUTURE_DIVISION)
SyntaxError: 'return' with argument inside generator (<console>, line 2)
do
without yield
works
=> (defn foo [n]
... (if (< n 10)
... (do
... (print "OK")
... (print "2nd"))
... (print "Fail")))
=> (foo 5)
OK
2nd
=> (foo 15)
Fail