Quick actions

cmd+k|ctrl+k

Navigation

Languages

Elixir pattern matching map in function

Snippet info

Language

Elixir

Visibility

public

Author

petter

Created

2015-09-07T19:38:20Z

Updated

2015-09-07T19:45:24Z

defmodule Main do

    def main() do
        http_map = %{"type" => "http", "http" => "http config"}
        tcp_map = %{"type" => "tcp", "tcp" => "tcp config"}
        handle(http_map)
        handle(tcp_map)
    end
    
    def handle(map=%{"type" => "http"}) do
        IO.puts "http handler: " <> map["http"]
    end
    
    def handle(map=%{"type" => "tcp"}) do
        IO.puts "tcp handler: " <> map["tcp"]
    end

end

Main.main
INFO