Use let scope to bing the agent
This commit is contained in:
parent
00385eee11
commit
c8f711e209
1 changed files with 25 additions and 24 deletions
|
|
@ -1,8 +1,6 @@
|
|||
(def agent-example
|
||||
"Agents provide shared access to mutable state."
|
||||
(agent 10))
|
||||
|
||||
(meditations
|
||||
(let [agent-example (agent 10)]
|
||||
|
||||
"Creating an Agent is as simple as assigning it a value"
|
||||
(= __ (instance? clojure.lang.Agent agent-example))
|
||||
|
||||
|
|
@ -28,4 +26,7 @@
|
|||
(try
|
||||
(send agent-example + 1)
|
||||
(catch IllegalStateException e))
|
||||
@agent-example)))
|
||||
@agent-example))
|
||||
|
||||
"It's a good idea to clean up any not finished agents after you are done"
|
||||
(shutdown-agents)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue