Methods having the same name might be distinguished by their argument lists.
Am I misunderstanding your reply?
Thanks!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Object doesn't have a getName() method.
If someone could file an issue on the clojure-site repo, I would be happy to improve the example.
Object doesn't have a getName() method.This doc is confusing - as Phill comments above, this is calling the getName() method on an instance of Class. In Clojure, a bare classname (String, ArrayList or whatever) resolves to the class itself if it has been imported (i.e. what would be String.class in Java). The doc is confusing because (.instanceMember Classname args*) is really just a special case of (.instanceMember instance args*), where "instance" refers to an instance of a Class object. I'm not sure why that doc makes that distinction, it doesn't seem useful to me.
(.instanceMember Classname args*) ==>
(. (identity Classname) instanceMember args*)
On Monday, March 20, 2017 at 4:59:33 PM UTC-4, Colin Fleming wrote:Object doesn't have a getName() method.This doc is confusing - as Phill comments above, this is calling the getName() method on an instance of Class. In Clojure, a bare classname (String, ArrayList or whatever) resolves to the class itself if it has been imported (i.e. what would be String.class in Java). The doc is confusing because (.instanceMember Classname args*) is really just a special case of (.instanceMember instance args*), where "instance" refers to an instance of a Class object. I'm not sure why that doc makes that distinction, it doesn't seem useful to me.
Oh. I see. `SomeClass` is an instance of java.lang.Class.
user=> (. (class String) getName)
"java.lang.Class"
Erf. Sorry. I don't think I understand that after all, and as well may have confused java.lang.String and java.lang.Class in my above reply.
I also notice now that:
user=> (class String)
java.lang.Class
but
user=> (. java.lang.Class getName)
CompilerException java.lang.NoSuchFieldException: getName, compiling:(/tmp/form-init2724986764275224936.clj:1:1)