Matt Brown wrote:
> Why does (. System getProperty "java.version") work when
> (. (identity System) getProperty "java.version") does not work, given
> that
> (identity System) should be the same as System ?
It's because the . special form treats class names specially. In Java
there's unfortunately a difference between instances of the
java.lang.Class object and the class itself. So:
Clojure: (. System getProperty "java.version")
Java: System.getProperty("java.version");
While:
Clojure: (. (identity System) getProperty "java.version") ; error!
Java: System.class.getProperty("java.version"); // error!
But if you call a method that exists on a java.lang.Class object it's okay:
(. (identity System) getMethods)
It's preferred style in Clojure to use this form to access static
methods and fields as it prevents this sort of confusion:
(System/getProperty "java.version")
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en