Tutorial by Examples

Add a -behaviour directive to your module to indicate that it follows a behaviour: -behaviour(gen_server). The American spelling is also accepted: -behavior(gen_server). Now the compiler will give a warning if you've forgotten to implement and export any of the functions required by the beha...
You can define your own behaviour by adding -callback directives in your module. For example, if modules implementing your behaviour need to have a foo function that takes an integer and returns an atom: -module(my_behaviour). -callback foo(integer()) -> atom(). If you use this behaviour in...
18.0 By default, any function specified in a -callback directive in a behaviour module must be exported by a module that implements that behaviour. Otherwise, you'll get a compiler warning. Sometimes, you want a callback function to be optional: the behaviour would use it if present and exported,...

Page 1 of 1