#--- # Excerpted from "Programming Elixir", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose. # Visit http://www.pragmaticprogrammer.com/titles/elixir for more book information. #--- defmodule Operators do defmacro a + b do quote do to_string(unquote(a)) <> to_string(unquote(b)) end end end defmodule Test do IO.puts(123 + 456) #=> "579" import Kernel, except: [+: 2] import Operators IO.puts(123 + 456) #=> "123456" end IO.puts(123 + 456) #=> "579"