Merge pull request #110 from iamvery/update-agents-koan

Show explicit example of named agents
This commit is contained in:
Uku Taht
2016-05-05 11:37:40 +01:00
2 changed files with 8 additions and 2 deletions

View File

@@ -2,8 +2,13 @@ defmodule Agents do
use Koans
koan "Agents maintain state, so you can ask them about it" do
Agent.start_link(fn() -> "Hi there" end, name: __MODULE__)
assert Agent.get(__MODULE__, &(&1)) == ___
{:ok, pid} = Agent.start_link(fn -> "Hi there" end)
assert Agent.get(pid, &(&1)) == ___
end
koan "Agents may also be named so that you don't have to keep the pid around" do
Agent.start_link(fn -> "Why hello" end, name: AgentSmith)
assert Agent.get(AgentSmith, &(&1)) == ___
end
koan "Update to update the state" do