# Pattern Matching Function (Without Equal Sign)

**URL:** <https://forum.elixirforum.com/t/pattern-matching-function-without-equal-sign/20909>\
**Category:** Questions\
**Tags:** pattern-matching, functions\
**Created:** [March 15, 2019, 6:55pm UTC](https://forum.elixirforum.com/t/pattern-matching-function-without-equal-sign/20909 "2019-03-15T18:55:23Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/32/27235_2.png) [@NobbZ](https://forum.elixirforum.com/u/NobbZ)\
**Post date:** [March 15, 2019, 7:13pm UTC](https://forum.elixirforum.com/t/pattern-matching-function-without-equal-sign/20909/7 "2019-03-15T19:13:53Z")

</div>

No, that match will fail as soon as you pass something into the function that is not a map, or if it is a map and does not have a key `:name`.

```plaintext
iex(1)> defmodule Greeter1 do
...(1)> def hello(%{name: person_name}) do
...(1)> IO.puts "Hello, " <> person_name
...(1)> end
...(1)> end
{:module, Greeter1,
 <<70, 79, 82, 49, 0, 0, 4, 248, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 162,
   0, 0, 0, 18, 15, 69, 108, 105, 120, 105, 114, 46, 71, 114, 101, 101, 116,
   101, 114, 49, 8, 95, 95, 105, 110, 102, 111, ...>>, {:hello, 1}}
iex(2)> Greeter1.hello(1)
** (FunctionClauseError) no function clause matching in Greeter1.hello/1

    The following arguments were given to Greeter1.hello/1:

        # 1
        1

    iex:2: Greeter1.hello/1
iex(2)> Greeter1.hello(%{})
** (FunctionClauseError) no function clause matching in Greeter1.hello/1

    The following arguments were given to Greeter1.hello/1:

        # 1
        %{}

    iex:2: Greeter1.hello/1
iex(2)> Greeter1.hello(%{sur_name: "Random"})
** (FunctionClauseError) no function clause matching in Greeter1.hello/1

    The following arguments were given to Greeter1.hello/1:

        # 1
        %{sur_name: "Random"}

    iex:2: Greeter1.hello/1
iex(2)> Greeter1.hello(%{name: "Random"})
Hello, Random
:ok
iex(3)> Greeter1.hello(%{name: "Random", sur_name: "Guy"})
Hello, Random
:ok 

```

---

_[View the full topic](https://forum.elixirforum.com/t/pattern-matching-function-without-equal-sign/20909)._
