Your Turn

  • Exercise: ControlFlow-2

    We now have three different implementations of FizzBuzz. One uses cond, one uses case, and one uses separate functions with guard clauses.

    Take a minute to look at all three. Which do you feel best expresses the problem. Which will be easiest to maintain?

    The case style and the implementation using guard clauses are different from control structures in most other languages. If you feel that one of these was the best implementation, can you think of ways to remind yourself to investigate these options as you write Elixir code in the future?

Get Programming Elixir 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.