Add Some Children

Before we start children, we’re going to need a GenServer. We’ll create a few fixed characters for our server. Our nonsensical app will say a quote from a famous character. As usual, we’ll put the business logic into a functional core.

Create a Core

Let’s create the core in super_duper/core.

 defmodule​ SuperDuper.Core ​do
 def​ say(​:superdave​) ​do
 "​​Next time you shoot a bullet at a metal object, watch the ricochet."
 end
 def​ say(​:superman​) ​do
 "​​It doesn't take X-Ray Vision to see you are up to no good."
 end
 def​ say(​:supermario​) ​do
 "​​Hoo hoo! Just what I needed!"
 end
 
 def​ info(name), ​do​: {name, say(name)}
 end

Our core has two pure functions. The say function has heads ...

Get Programmer Passport: OTP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.