Java Interop with Clojure

Discussion in 'Programming' started by Proximyst, Apr 18, 2017.

Thread Status:
Not open for further replies.
  1. So, I can write the following in Clojure using the JDA API:
    Code (Java):
    (.getName guild)
    Guild is then from net.dv8tion.jda.core.entities.Guild and is not nil.
    It casts this to java.lang.Class, though, as it's calling "getName", which cannot be anything else, according to Clojure.
    I cannot write anything like this either, though, as it isn't valid:
    Code (Java):
    (Guild.getName guild)
    ; ^ not valid
    (Guild/getName guild)
    ; ^ not valid
    (guild.getName)
    ; ^ at least not valid
    (guild/getName)
    ; ^ how can this ever be valid
    does anyone know what to do here? I mean, I can just make a java class to do this statically, but I prefer not to.

    EDIT: Solved using Type Hinting.
     
    #1 Proximyst, Apr 18, 2017
    Last edited: Apr 18, 2017
Thread Status:
Not open for further replies.