Latest #pattern-matching Threads 
Is it possible to match multiple parameters to a single function body? So for:
def foo("a" = word) do
word
end
def foo("b" = word) do
...
New
An in-depth guide on how to pattern match against binary data in Elixir.
New
Hi! I might be asking a silly one, sorry for that and thanks for your time!
my aim is to implement quite simple logic:
the get_or_creat...
New
I’m not fully understanding how matching works with function arguments. In Functions and Pattern Matching it is explained (IMO poorly) th...
New
defmodule Navigator do
def navigate(dir) do
expanded_dir = Path.expand(dir)
go_through([expanded_dir])
end
def go_through...
New
Hey all!
I’m releasing TaggedTupleShorthand today as an experiment with Elixir syntax.
Field Punning
The aim of the library is to suppo...
New
Hi folks!
With the new release of Elixir 1.18, I would like to enforce pattern-matching by struct in our projects to take advantage of t...
New
I’ve got this bit of code; I’m wondering why create_or_open_room always creates a new room, even when there is an existing child process ...
New
I have a case clause (contrived for the purpose of this question):
level = 4
has_children_or_no_children = :no_children
case {level, ha...
New
I was wondering if there is a way to return both the variables (e.g., :“$1”), and its matched value with a single call to :ets.select(tab...
New
This Week's Trending
This Month's Trending
This Year's Trending
Is it possible to match multiple parameters to a single function body? So for:
def foo("a" = word) do
word
end
def foo("b" = word) do
...
New
Hi! I might be asking a silly one, sorry for that and thanks for your time!
my aim is to implement quite simple logic:
the get_or_creat...
New
An in-depth guide on how to pattern match against binary data in Elixir.
New
Last Three Year's Trending
How can I pattern match against an arbitrary sized tuple? This works:
{status, _, _} = {:ok, 1, 2}
But what if I don’t know the structu...
New
Hi,
I was surprised I couldn’t find any argument on this on the net so here I am.
When you make recursive function that deal with list ...
New
Say I have a very large data structure who’s size is in the 10s of MB. This structure is arbitrarily complex, consisting of many tuples ...
New
iex(26)> "hello " <> matched = "hello world"
"hello world"
iex(27)> matched
"world"
iex(28)> matched <> " world" = "...
New
Hi! Quick question from a guy coming from Javascript:
Whenever I have to handle some conditional behavior, like ‘do something depending ...
New
I’m not fully understanding how matching works with function arguments. In Functions and Pattern Matching it is explained (IMO poorly) th...
New
Hello, I have been developing a simple macro and now I want to improve it and let it accept nested option.
For example:
guardedstruct do...
New
I was wondering if there is a way to return both the variables (e.g., :“$1”), and its matched value with a single call to :ets.select(tab...
New
I’m trying to build a simple function to see if a user is authorized to join a conversation. Basically, it needs to query the mysql datab...
New
I’ve got this bit of code; I’m wondering why create_or_open_room always creates a new room, even when there is an existing child process ...
New
version
elixir: 1.16.0
erlang: 26.2.1
Hi! When I used pattern match with japanese words like this below
String.match?("あ", ~r/[りんご]/)...
New
Hey all!
I’m releasing TaggedTupleShorthand today as an experiment with Elixir syntax.
Field Punning
The aim of the library is to suppo...
New
Hi folks!
With the new release of Elixir 1.18, I would like to enforce pattern-matching by struct in our projects to take advantage of t...
New
defmodule Navigator do
def navigate(dir) do
expanded_dir = Path.expand(dir)
go_through([expanded_dir])
end
def go_through...
New
I have a case clause (contrived for the purpose of this question):
level = 4
has_children_or_no_children = :no_children
case {level, ha...
New
Trending Over Three Years
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
Rust has a very nice semantics for Option<T> and Result<T,E> These two have similar uses but have a clear distinction about e...
New
What is the best solution if I want to try to pattern match and do something else if no match was found?
Let’s say, I want to pattern ma...
New
Given these two maps:
map1 = %{a: 1}
map2 = %{a:1, b: 2}
This works fine:
%{a: 1} = map2
But these do not:
iex> ^map1 = map2
*...
New
Hello everybody,
As it’s possible to partially pattern match with maps like so:
iex> %{b: 2} = %{a: 1, b: 2, c: 3}
%{a: 1, b: 2, c: ...
New
I have the following code:
defp has_char_in_string?(value), do: Regex.match?(~r/[^\d]/, value)
def somefun(arg) do
case has_char_...
New
This is more of a general question, but I’m wondering how other people in the community think about the pattern matching in function sign...
New
I have seen the pattern %_{} being used to match against structs (notice the _ after the %).
Is this documented somewhere? It seems to m...
New
Im trying to get one element and the rest of the map with pattern matching but I’m only get compile errors.
I came up with this:
%{“One...
New
I refactored a code from:
def do_something(attribute) do
bar = get_bar(attribute)
baz = get_baz(bar)
do_something_else(attribute,...
New
We can match arguments like this in elixir:
iex(1)> f = fn(a, [b: a]) -> a end
...
New
So I've been working on some projects that envolve external services/API's that provide data in XML and JSON. In some of these services I...
New
Hi there,
I have a controller with an action that renders some html. Now I want to extend that action to render some json when the conte...
New
So I have looked for this topic and found similar ones but not actually this one. Forgive me if I missed it.
While I really love Elixirs...
New
Latest on Elixir Forum
Get money off!
The Pragmatic Bookshelf
35% off any eBook
Manning Publications
45% off any item
ElixirCasts
10% off for life
The Pragmatic Studio
20% off any course
AppSignal
10% off for 12 months
Honeybadger
10% off for 12 months
Simply use coupon code "devtalk.com" or "elixirforum" at checkout!
Filter by Type:
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #exunit
- #elixirconf
- #discussion
- #javascript
- #podcasts
- #code-sync
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #api
- #processes
- #forms
- #metaprogramming
- #security
- #performance
- #hex







