This Week's Trending Top

This Month's Trending Top

This Year's Trending Top

spammy
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
spacemonk
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

Last Three Year's Trending Top

ollran
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
gameline
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
mpope
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
spencer.christensen
iex(26)> "hello " <> matched = "hello world" "hello world" iex(27)> matched "world" iex(28)> matched <> " world" = "...
New
Gonza
Hi! Quick question from a guy coming from Javascript: Whenever I have to handle some conditional behavior, like ‘do something depending ...
New
Parashoe
I’m not fully understanding how matching works with function arguments. In Functions and Pattern Matching it is explained (IMO poorly) th...
New
shahryarjb
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
Leo-Nogismus
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
peppy
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
James_E
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
sora1
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
gperales
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
donnieparka
defmodule Navigator do def navigate(dir) do expanded_dir = Path.expand(dir) go_through([expanded_dir]) end def go_through...
New
cd-slash
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 Top

sergio_101
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
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
minhajuddin
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
abraun
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
axelson
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
Sanjibukai
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
henrique-marcomini-m
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
minhajuddin
I have seen the pattern %_{} being used to match against structs (notice the _ after the %). Is this documented somewhere? It seems to m...
New
marioalvial
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
vinibrl
I refactored a code from: def do_something(attribute) do bar = get_bar(attribute) baz = get_baz(bar) do_something_else(attribute,...
New
ijverig
We can match arguments like this in elixir: iex(1)> f = fn(a, [b: a]) -> a end ...
New
sashaafm
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
inhji
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
sagnik2911
Here nums is a list of [list of {tuples}]. nums = [[{5,2}], [{10,2},{4,5}], [{6,5},{3,10},{2,15}]] I want to print output like this: 1...
New
startledhippo
Hi, Given test = %{a: 1, b: [%{c: 1,d: 2}] } How do I pattern match to get values c and d? I tried the following: %{a: a, [%{c: va...
New
  • Follow
  • Join
  • Shape
the conversation

Latest on Elixir Forum

Elixir Forum

Similar Portals

    None added yet

We're in Beta

About us Mission Statement