Funções anônimas
Last updated
defmodule FunctionTest do
use ExUnit.Case
# ...
test "success" do
sum = fn x, y -> x + y end
assert sum(10) == 100
end
endmix test test/function_test.exs
warning: variable "sum" is unused (if the variable is not meant to be used, prefix it with an underscore)
test/function_test.exs:9: FunctionTest."test success"/1
== Compilation error in file test/function_test.exs ==
** (CompileError) test/function_test.exs:11: undefined function sum/1 (expected FunctionTest to define such a function or for it to be imported, but none are available)Enum.map([1, 2, 3], fn x -> x * 2 end