diff --git a/ideaboard.txt b/ideaboard.txt index 710bac9..850e43e 100644 --- a/ideaboard.txt +++ b/ideaboard.txt @@ -1,7 +1,6 @@ Concepts / Language Features ===== new record syntax -Agents Vars state identity lifetime Metadata diff --git a/resources/koans.clj b/resources/koans.clj index c461f60..eefe531 100644 --- a/resources/koans.clj +++ b/resources/koans.clj @@ -208,4 +208,4 @@ 10 10 12 - IllegalStateException]}]] + 12]}]] diff --git a/src/koans/21_agents.clj b/src/koans/21_agents.clj index 1806f2d..4b02fd1 100644 --- a/src/koans/21_agents.clj +++ b/src/koans/21_agents.clj @@ -9,23 +9,23 @@ "To get agent's value you dereference it" (= __ @agent-example) - "To set a new value, you use send or send-all functions, but you can't just send anything.." - (= __ (do - (set-error-mode! agent-example :continue) - (send agent-example 20) - @agent-example)) - - "Send takes a function and arguments and sends them to the agent. The send function, - returns immediately, but the action is prccessed in a separate thread and it's the result, + "To change agent's value you use send function - you pass action and action's arguments to it. + Send function, returns immediately, but the action is prccessed in a separate thread and it's the result, of that action that gets assigned to agent's state" (= __ (do (send agent-example + 2) @agent-example)) + "You can't just send a value to agent" + (= __ (do + (set-error-mode! agent-example :continue) + (send agent-example 20) + @agent-example)) + "You can create validations for states that agent is allowed to take" (= __ (do (set-validator! agent-example #(even? %)) (try (send agent-example + 1) (catch IllegalStateException e)) - (agent-error agent-example)))) + @agent-example)))