     register pid
   end
 
-  def ticker(next_client \\ self) do
-    :global.register_name @name, self
+  def ticker(next_client \\ self()) do
+    :global.register_name @name, self()
     receive do
       { :register, new_client } ->
         IO.puts "registering #{inspect new_client}"

defmodule Ticker04 do

  def start do
    spawn(__MODULE__, :generator, [])
  end

  def add_client do

    end
  end

  def receiver(next_client \\ self()) do
    receive do
      { :tick, new_client } -> # 引数有りで呼び出された場合は引数PIDにsendする。
        IO.puts "first tock in #{inspect self()}, sending a tick to #{inspect new_client} in 2s"
        ticker(new_client)
      { :tick } -> # 引数なしだった場合は自分にsendする。
        IO.puts "tock in #{inspect self()}, sending a tick to #{inspect next_client} in 2s"
        ticker(next_client)
    end
  end
