Created
June 15, 2013 13:07
-
-
Save bryanwb/5788068 to your computer and use it in GitHub Desktop.
elixir question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# how does the handle_cast :push change the stack variable? | |
defmodule Stacker.Server do | |
use GenServer.Behaviour | |
def init(stack) do | |
{ :ok, stack } | |
end | |
def handle_call(:pop, _from, [h|stack]) do | |
{ :reply, h, stack } | |
end | |
def handle_cast({ :push, new }, stack) do | |
{ :noreply, [new|stack] } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment