Skip to content

Instantly share code, notes, and snippets.

@joehakimrahme
Created June 24, 2013 21:55
Show Gist options
  • Save joehakimrahme/5853968 to your computer and use it in GitHub Desktop.
Save joehakimrahme/5853968 to your computer and use it in GitHub Desktop.

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