`
ClojureScript 1.10.339
cljs.user=> (defn foo ([x] [:single x]) ([& xs] [:variadic xs]))
'cljs.user/foo
cljs.user=> (foo 1)
[:single 1]
cljs.user=> (foo 1 2)
[:variadic 1]
`
请注意,可变参数调用提供了错误的答案。
正确的做法似乎不是“让它工作”,而是拒绝作为错误的代码。请参阅Clojure
user=> (defn foo ([x] [:single x]) ([& xs] [:variadic xs])) CompilerException java.lang.RuntimeException: Can't have fixed arity function with more params than variadic function, compiling:(NO_SOURCE_PATH:1:1)