Your Turn

  • Exercise: Functions-4

    Write a function prefix that takes a string. It should return a new function that takes a second string. When that second function is called, it will return a string containing the first string, a space, and the second string.

    iex>​ mrs = prefix.(​"Mrs"​)
    iex>​ mrs.(​"Smith"​)
    "Mrs Smith"​​​
    iex>​ prefix.(​"Elixir"​).(​"Rocks"​)
    "Elixir Rocks"

Get Programming Elixir now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.