Skip to content

Instantly share code, notes, and snippets.

@sw-samuraj
Created December 17, 2019 16:00
Show Gist options
  • Save sw-samuraj/cd0c97c540846b0e07e0e9bfe4771cab to your computer and use it in GitHub Desktop.
Save sw-samuraj/cd0c97c540846b0e07e0e9bfe4771cab to your computer and use it in GitHub Desktop.
(def counter (ref 0 :validator number?))
; #'user/counter
(dosync (ref-set counter "string"))
; IllegalStateException Invalid reference state clojure.lang.ARef.validate (ARef.java:33)
@counter
; 0
(dosync (ref-set counter 42))
; 42
@counter
; 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment