Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment