我很難理解默認參數如何與命名函數中的多個子句進行交互。歸結起來,爲什麼下面的代碼段工作? defmodule Lists do
def sum([], total \\ 0), do: total
def sum([h|t], total), do: h + sum(t, total)
end
從我的理解這被編譯器擴展爲: defmodule Lists do
我使用Erlang的Web框架:cowboy在靈藥,而我在:cowboy_http_req.reply得到一個錯誤使用的牛仔,這裏是我的代碼: mix.exs是: defmodule Example.Mixfile do
use Mix.Project
def project do
[ app: :example,
version: "0.0.1",