# Boolean expression pattern matching with tuples

**URL:** <https://forum.elixirforum.com/t/boolean-expression-pattern-matching-with-tuples/66545>\
**Category:** Questions\
**Tags:** pattern-matching, learning-elixir\
**Created:** [October 6, 2024, 3:01pm UTC](https://forum.elixirforum.com/t/boolean-expression-pattern-matching-with-tuples/66545 "2024-10-06T15:01:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![sbuttgereit](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sbuttgereit/32/30162_2.png) [@sbuttgereit](https://forum.elixirforum.com/u/sbuttgereit)\
**Post date:** [October 6, 2024, 3:18pm UTC](https://forum.elixirforum.com/t/boolean-expression-pattern-matching-with-tuples/66545/2 "2024-10-06T15:18:30Z")

</div>

> [@cd-slash](#):
>
> ```elixir
> case {level, has_children_or_no_children} do
> {n when n < 5, :has_children} ->
> 1
> 
> {n when n > 0, :no_children} ->
> 2
> 
> _ ->
> false
> end
> 
> ```

The guard needs to be outside of the match:

```elixir
case {level, has_children_or_no_children} do
  {n, :has_children} when n < 5 -> 1
  {n, :no_children} when n > 0 -> 2
  _ -> false
end

```

---

_[View the full topic](https://forum.elixirforum.com/t/boolean-expression-pattern-matching-with-tuples/66545)._
