Skip to content

Instantly share code, notes, and snippets.

@bryanwb
Created June 15, 2013 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanwb/5788068 to your computer and use it in GitHub Desktop.
Save bryanwb/5788068 to your computer and use it in GitHub Desktop.
elixir question
# 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