The following code is somewhat surprising to me:
user> (def bla (filter #(throw (Exception. %)) ["lol" "foo"]))
;; => #'user/bla
user> (prn bla)
Execution error at sun.reflect.NativeConstructorAccessorImpl/newInstance0 (NativeConstructorAccessorImpl.java:-2).
lol
(
user> (prn bla)
()
;; => nil
user>
That the def
doesn't throw is expected, that the first prn
throws is also expected.
What's unexpected is that the second prn
returns the empty list.
Digging a bit more, it turns out that removing the :once
meta on lazy-seq
, I get expected behaviour, ie the second prn
throws too.