defmodule Hello do
IO.puts "Defining the function world"
def world do
IO.puts "Hello World"
end
IO.puts "Function world defined"
end
Hello.world
<p class="indent">
结果输出: Defining the function world Function world defined Hello World
可以进行元编程和DSL:
defmodule MathTest do
use ExUnit.Case
test "can add two numbers" do
assert 1 + 1 == 2
end
end
<p class="indent">