dtw0sg
Last Updated: February 25, 2016
·
2.969K
· runexec
81609937c20aeab3598aea56f1f4f022

Unique IDs in Clojure

endorse

(defn new-uuid []
      (java.util.UUID/randomUUID))
Say Thanks
Respond

1 Response
Add your response

17561
Photo

Should be cast to string i guess :

user=> (java.util.UUID/randomUUID)
#uuid "a667e449-d9a0-43d2-ab33-618a3b56ab7e"
user=> (type (java.util.UUID/randomUUID))
java.util.UUID

(defn new-uuid 
  "Retrieve a type 4 (pseudo randomly generated) UUID. The UUID is generated using a cryptographically strong pseudo random number generator." 
  []
  (str (java.util.UUID/randomUUID)))
over 1 year ago ·