From Ruby to Elixir: example_server.ex code not working (page 74)

@sb8244

The code example for Examples.GenServer.SimpleServer.add/3 function does not work for me as written. I was able to get it to work by switching the function arguments so that the server was the first argument rather than the last.

1 Like

I see the issue here. In the command line demo, I put pid first instead of last. Here’s a switched version:

I like to put the pid as the last argument because it’s often left optional when using named processes. This is because you will often pass the pid in test file but not in your app. Happy to go into more detail if needed.

:facepalm: This makes perfect sense. Thank you!