fmcgeough
pipe into case? I use that fairly frequently…unless I’m misunderstanding what you’re wanting…could be.. its still very early…
str = "Hello"
str |> case do
"Goodbye" -> "see ya!"
"Hello" -> "welcome!"
end
Trending in Guides/Tuts
# ~/src/livebook/.iex.exs
System.cmd("xdg-open", [ LivebookWeb.Endpoint.access_url() ] )
Because Livebook requires a unique passcode on ...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
Yep this! I pipe into case statements probably a lot more excessively than I really should… ^.^;
And I pipe into
ifand other such things as well… >.>jeremyjh
Oh my…so much code I have to rewrite now! Wow thats something I really…should have…checked.
AstonJ
Cool tip - moved into a new thread
joaoevangelista
OMG, just please don’t pipe when you don’t need it, I just don’t see any improvement when piping for example just one time e.g.
mylist |> Enum.map(myfunc). It is such less readable, just because you can, it doesn’t mean you shouldyawaramin
Yup!
One pipe–not worth it.
Two or more pipes–extremely worth it
sztosz
I always find this
something |> IO.inspect()more readable thanIO.inspect(something)I really don’t see nothing wrong with piping even when there is only one pipeIf you do
then what’s wrong with just
I think we should not mistake readability with familiarity. Just my 2 cents.
joaoevangelista
Yet in the end it is just personal taste I think. for people’s doing elixir It is pretty normal, new devs coming to the code base might not get over it easily. I just think that reading
this piped into IO.inspectis less readable thanIO.inspect thisbecause it looks more like a description of a command. And reaching for|and>is harddbern
Piping into
caseis pretty cool, but after I do it, I realize it’s often better for me to wrap that case statement into a function that I can name so it reveals the intention a little better.I especially don’t like doing it in the middle of a pipeline. I find myself using case statements more often in Phoenix controllers to handle the happy path and unhappy path.
NobbZ
This style often confused subject and object. Therefore I’m not really a friend of it.
joaoevangelista
Also a fan of that, and we can use pattern matching in the head of the function as each case match, since both will be compiled down to the same thing