• ؔએݴͰ͑ΔͷͰɺif-elseͰ݅ذͤͯ͞ݺͼग़ؔ͢Λಛఆ͢Δඞཁ͕ͳ͍ • ͲͷҾͷύλʔϯͳΒɺͲͷ͕ؔݺΕΔ͔Ұྎવ • ໊ؔͱҾͷύλʔϯΛಡΊɺΠνΠνதΛಡ·ͳͯ͘ཧղͰ͖Δ defmodule Sample.PatternMatchSample do def get(url) do process_response http_get(url) end defp process_response(%{status_code: 301, headers: headers}) do redirect headers end defp process_response(%{status_code: 302, headers: headers}) do redirect headers end defp process_response(%{status_code: 200, body: body}) do IO.puts body end defp redirect(headers) do headers |> Dict.get(:Location) |> get end end Ref. Elixir ͷύλʔϯϚονΛ߈ུ͠Α͏
ͧ E l i x i r • հ͖͠Εͳ͍ັྗͷʑ • ؔܕϓϩάϥϛϯάʗσʔλͷෆมੑʗࢀরಁաੑ • ϚΫϩʹΑΔϝλϓϩάϥϛϯά • ϑΝʔετΫϥευΩϡϝϯτʗDoctests • ͱΓ͋͑ͣͪΐͬͱͬͯΈΑ͏ʂͳͬʂʁ • http://elixir-lang.org/getting-started/introduction.html