summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHassan Shaikley <hassan.shaikley@gmail.com>2019-06-15 03:03:51 -0700
committerEric Meadows-Jönsson <eric.meadows.jonsson@gmail.com>2019-06-15 12:03:51 +0200
commitc88bb83e42eebd3c1c0d3fb701057a4c3832f136 (patch)
tree54b0e16ceffdcc447b03ac16de6217c02d620e89
parentfedcff15977930db980faca51580f1a3a94e9439 (diff)
downloadelixir-c88bb83e42eebd3c1c0d3fb701057a4c3832f136.tar.gz
Add example for Agent.cast/2 (#9142)
-rw-r--r--lib/elixir/lib/agent.ex9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/elixir/lib/agent.ex b/lib/elixir/lib/agent.ex
index 36e80179b..51f9e8c8d 100644
--- a/lib/elixir/lib/agent.ex
+++ b/lib/elixir/lib/agent.ex
@@ -439,6 +439,15 @@ defmodule Agent do
Note that `cast` returns `:ok` immediately, regardless of whether `agent` (or
the node it should live on) exists.
+
+ ## Examples
+
+ iex> {:ok, pid} = Agent.start_link(fn -> 42 end)
+ iex> Agent.cast(pid, fn state -> state + 1 end)
+ :ok
+ iex> Agent.get(pid, fn state -> state end)
+ 43
+
"""
@spec cast(agent, (state -> state)) :: :ok
def cast(agent, fun) when is_function(fun, 1) do