-
-
Save freeeve/3893259 to your computer and use it in GitHub Desktop.
Evaling an anonymous function with closure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns why-is-that.core) | |
(def test-1 (list (fn [arg] | |
arg) 1)) | |
;; (eval test-1) -> 1 | |
(def test-2 (list ((fn [] | |
(fn [arg] | |
['hello arg]))) 1)) | |
;; (eval test-2) -> [hello 1] | |
(def test-3 (list ((fn [argname] | |
(fn [arg] | |
[argname arg])) 'test) 1)) | |
;; (eval test-3) -> IllegalArgumentException No matching ctor found for class why_is_that.core$fn__1971$fn__1972 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment