Skip to content

Instantly share code, notes, and snippets.

@noisesmith
Created September 13, 2016 23:54
Show Gist options
  • Select an option

  • Save noisesmith/bf55a69b223a6762df4f30cf4a675daf to your computer and use it in GitHub Desktop.

Select an option

Save noisesmith/bf55a69b223a6762df4f30cf4a675daf to your computer and use it in GitHub Desktop.
default method on LazyDelay protocol
kingfisher.core=> (defprotocol LazyDelay (default [this x]))
LazyDelay
kingfisher.core=> (extend-protocol LazyDelay clojure.lang.Delay (default [this x] (if (realized? this) @this x)))
nil
kingfisher.core=> (def d (delay 42))
#'kingfisher.core/d
kingfisher.core=> (default d 12)
12
kingfisher.core=> @d
42
kingfisher.core=> (default d 12)
42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment