How do you return from a function early in Clojure?

后端 未结 8 1268
不知归路
不知归路 2020-12-08 13:48

Common Lisp has return-from; is there any sort of return in Clojure for when you want to return early from a function?

8条回答
  •  爱一瞬间的悲伤
    2020-12-08 14:10

    In short, no. If this is a real problem for you then you can get around it with "the maybe monad" Monads have a high intellectual overhead so for many cases clojurians tend to avoid the "if failed return" style of programming.

    It helps to break the function up into smaller functions to reduce the friction from this.

提交回复
热议问题