# \#function-clause

**URL:** https://forum.elixirforum.com/tag/function-clause/624.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [How to distribute function clauses over several files](https://forum.elixirforum.com/t/how-to-distribute-function-clauses-over-several-files/42286)

<div class="topic-metadata">

**Author:** [@MMore](https://forum.elixirforum.com/u/MMore)\
**Replies:** 2\
**Last updated:** [September 11, 2021, 11:10am UTC](https://forum.elixirforum.com/t/how-to-distribute-function-clauses-over-several-files/42286 "2021-09-11T11:10:23Z")

</div>

Hello Hello, I have a bunch of function clauses (means one function, but different clauses to match for different input parameters). This function is basically an API handler. def handle\_event\_type(event\_type = "car\_st…

---

## [\_\_using\_\_ modules to share private functions... ordering functions?](https://forum.elixirforum.com/t/using-modules-to-share-private-functions-ordering-functions/29748)

<div class="topic-metadata">

**Author:** [@fireproofsocks](https://forum.elixirforum.com/u/fireproofsocks)\
**Replies:** 5\
**Last updated:** [March 11, 2020, 4:00am UTC](https://forum.elixirforum.com/t/using-modules-to-share-private-functions-ordering-functions/29748 "2020-03-11T04:00:48Z")

</div>

This is a code style question (mostly?). I’m using use and the \_\_using\_\_ macro to share private functions between other modules. The functions have the same name and arity: the idea is that they get called recursively …

---

## [Fix definitions with multiple clauses and optional values that only have 1 param](https://forum.elixirforum.com/t/fix-definitions-with-multiple-clauses-and-optional-values-that-only-have-1-param/19585)

<div class="topic-metadata">

**Author:** [@Fl4m3Ph03n1x](https://forum.elixirforum.com/u/Fl4m3Ph03n1x)\
**Replies:** 4\
**Last updated:** [January 22, 2019, 10:54am UTC](https://forum.elixirforum.com/t/fix-definitions-with-multiple-clauses-and-optional-values-that-only-have-1-param/19585 "2019-01-22T10:54:28Z")

</div>

I have the following code in my GenServer: def init(%State{} = state), do: {:ok, state, 1\_000} def init(opts \\\\ \[\]) do state = struct(State, opts) {:ok, state, 1\_000} end This code, as some of you may guess will ge…

---

## [Passing captured named function requiring arguments to another function?](https://forum.elixirforum.com/t/passing-captured-named-function-requiring-arguments-to-another-function/14179)

<div class="topic-metadata">

**Author:** [@tme\_317](https://forum.elixirforum.com/u/tme_317)\
**Replies:** 7\
**Last updated:** [May 13, 2018, 10:29am UTC](https://forum.elixirforum.com/t/passing-captured-named-function-requiring-arguments-to-another-function/14179 "2018-05-13T10:29:55Z")

</div>

I’ve been struggling with this for a few hours now and there must be an easy answer despite my inability to search and find answers. So I have this pretty simple code: def tcp\_port\_open?(host, port) do case :gen\_…

---

## [Parameter pattern matching](https://forum.elixirforum.com/t/parameter-pattern-matching/14173)

<div class="topic-metadata">

**Author:** [@laiboonh](https://forum.elixirforum.com/u/laiboonh)\
**Replies:** 7\
**Last updated:** [May 12, 2018, 4:42pm UTC](https://forum.elixirforum.com/t/parameter-pattern-matching/14173 "2018-05-12T16:42:22Z")

</div>

Can someone explain to me how parameter pattern matching works exactly? def foo({a,b}) do ... end foo({1,2}) Pattern matching that happens: {a,b} = {1,2} def equal(a,a), do: true equal(1,1) Pattern matching that hap…
