O'Reilly logo

Learning Elixir by Kenny Ballou

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

Summary

In this chapter, we discussed a number of topics concerning Elixir and metaprogramming.

Typespecs are used as a means for documenting code (with code) such that other programmers (and ourselves) will know at a glance the expected types of certain functions. Typespecs are also a great tool for annotating code, functions, and modules for static analysis, and for finding type issues or other bugs typically unavailable to dynamically-typed languages.

Behaviours can be thought of akin to interfaces from OO languages. They are a means to define modules that will have a set of public functions with specific arity. If the modules adopting a behaviour do not define any or all of the functions from the behaviour, Elixir will raise a compiler warning. ...

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