iexnotes 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. iex(1)> {:ok, pid} = ABCD.Fourletters.start_link([])
  2. {:ok, #PID<0.350.0>}
  3. iex(2)> ABCD.Fourletters.get(pid)
  4. []
  5. iex(3)> ABCD.Fourletters.put(pid, "he")
  6. :ok
  7. iex(4)> ABCD.Fourletters.get(pid)
  8. ["he"]
  9. iex(5)> ABCD.Fourletters.put(pid, "he")
  10. :ok
  11. iex(6)> ABCD.Fourletters.get(pid)
  12. ["he", "he"]
  13. iex(7)> [%{id: :aoeu, start: {ABCD.Fourletters, :start_link, [[]]}}]
  14. [%{id: :aoeu, start: {ABCD.Fourletters, :start_link, [[]]}}]
  15. iex(8)> # iex(2)> {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)
  16. nil
  17. iex(9)> children = [%{id: :aoeu, start: {ABCD.Fourletters, :start_link, [[]]}}]
  18. [%{id: :aoeu, start: {ABCD.Fourletters, :start_link, [[]]}}]
  19. iex(10)> {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)
  20. {:ok, #PID<0.361.0>}
  21. iex(2)> {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)
  22. {:ok, #PID<0.366.0>}
  23. iex(3)> Supervisor.count_children(pid)
  24. %{active: 1, specs: 1, supervisors: 0, workers: 1}
  25. iex(4)> Supervisor.start_child(pid,
  26. ...(4)> %{id: :aoeu, start: {ABCD.Fourletters, :start_link, [[]]}})
  27. {:error, {:already_started, #PID<0.367.0>}}
  28. iex(5)> %{id: :tutu, start: {ABCD.Fourletters, :start_link, [[]]}})
  29. ** (SyntaxError) iex:5:59: unexpected token: )
  30. iex(5)> Supervisor.start_child(pid, %{id: :tutu, start: {ABCD.Fourletters, :start_link, [[]]}})
  31. {:ok, #PID<0.373.0>}
  32. iex(6)> Supervisor.count_children(pid)
  33. %{active: 2, specs: 2, supervisors: 0, workers: 2}
  34. iex(7)> {:error, {:already_started, child_pid}} = Supervisor.start_child(pid, %{id: :tutu, start: {ABCD.Fourletters, :start_link, [[]]}})
  35. {:error, {:already_started, #PID<0.373.0>}}