O'Reilly logo

Programming Elixir by Dave Thomas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Your Turn

  • Exercise: LinkingModules-BehavioursAndUse-1

    In the body of the def macro, there’s a quote block that defines the actual method. It contains

     
    IO.puts ​"==> call: #{Tracer.dump_definition(unquote(name), unquote(args))}"
     
    result = ​unquote​(content)
     
    IO.puts ​"<== result: #{result}"

    Why does the first call to puts have to unquote the values in its interpolation but the second call does not?

  • Exercise: LinkingModules-BehavioursAndUse-2

    The built-in function IO.ANSI.escape will insert ANSI escape sequences in a string. If you put the resulting strings into a terminal, you can add colors and bold or underlined text. Explore the library, and then use it to colorize our tracing’s output.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required