supers

clojure.core

  • (supers class)
Returns the immediate and indirect superclasses and interfaces of c, if any

1 Example top

  • ;;find superclasses and interfaces of Java objects...
    user> (supers Object)
    nil
    
    user> (supers String)
    #{java.lang.Comparable java.lang.CharSequence java.io.Serializable java.lang.Object}
    
    ;;...or Java interfaces
    user> (supers javax.naming.Name)
    #{java.lang.Cloneable java.lang.Comparable java.io.Serializable}
    
    ;;Also with clojure types...
    user> (defrecord MyThing [a b c])
    user.MyThing
    
    user> (supers MyThing)
    #{clojure.lang.Counted java.lang.Iterable clojure.lang.IKeywordLookup clojure.lang.IObj clojure.lang.IPersistentMap clojure.lang.Associative clojure.lang.Seqable java.util.Map clojure.lang.IMeta java.io.Serializable java.lang.Object clojure.lang.IPersistentCollection clojure.lang.ILookup}
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:4856 top

(defn supers
  "Returns the immediate and indirect superclasses and interfaces of c, if any"
  {:added "1.0"
   :static true}
  [^Class class]
  (loop [ret (set (bases class)) cs ret]
    (if (seq cs)
      (let [c (first cs) bs (bases c)]
        (recur (into1 ret bs) (into1 (disj cs c) bs)))
      (not-empty ret))))
Vars in clojure.core/supers:
Used in 0 other vars

Comments top

No comments for supers. Log in to add a comment.