realized?

clojure.core

  • (realized? x)
Returns true if a value has been produced for a promise, delay, future or lazy sequence.

1 Example top

  • ;; Create a promise
    user> (def p (promise))
    #'user/p ; p is our promise
    
    ;; Check if was delivered/realized
    user> (realized? p)
    false ; No yet
    
    ;; Delivering the promise
    user> (deliver p 42)
    #<core$promise$reify__5727@47122d: 42>
    
    ;; Check again if it was delivered
    user> (realized? p)
    true ; Yes!
    
    ;; Deref to see what has been delivered
    user> @p
    42
    
    ;; Note that @ is shorthand for deref
    user> (deref p)
    42
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:6502 top

(defn realized?
  "Returns true if a value has been produced for a promise, delay, future or lazy sequence."
  {:added "1.3"}
  [^clojure.lang.IPending x] (.isRealized x))
Vars in clojure.core/realized?:
Used in 0 other vars

Comments top

No comments for realized?. Log in to add a comment.