News for hackers. Stuff that matters.
Re:Cursed Elixir by zapnuk on Monday October 19, 2020 @04:15AM (#24824242)
Edit: My bad didn't recognize the parent comment was about Ruby, and that the code isn't elixir by a long way.

Correct me if I'm wrong but I think there are 1 (and a half) other ways you could write it - that don't result in branching

1:

  def something(args) do
    with {:ok, obj1} <- depencency1.call(args),
         {:ok, obj2} <- dependency2.call(obj1),
         {:ok, obj3} <- dependency2.call(obj2),
         {:ok, obj4} <- dependency2.call(obj3),
         {:ok, obj5} <- dependency2.call(obj4)
    do
      {:ok, obj5}
    else
      {:error, msg} -> {:error, msg}
    end
  end

1.5: Use a try/rescue block where you match {:ok, obj} and then catch Match errors.
Re:Cursed Elixir by Gaelan on Monday October 19, 2020 @04:39AM (#24824357)
I think your parent was writing Ruby, not Elixir. (Unless this is Ruby's new pattern-matching syntax that I'm not familiar with.)
Re:Cursed Elixir by Fire-Dragon-DoL on Monday October 19, 2020 @08:49AM (#24825814)
Indeed if you look at my ruby code, it tries to be a with statement ;)
Re:Cursed Elixir by rkangel on Monday October 19, 2020 @05:22AM (#24824634)
The parent is referring to rubocop, so I think they're talking about Ruby.

The Elixir formatter sounds much less strict, and I have very little problem with it.