Running the new Elixir formatter

Hi,

I like the new code formatter. I just noticed an inconsistency though between the with and if formats:

  def new(type, %Coord{} = origin) when type in @types do
    with %MapSet{} = coords <- coords(@offsets[type], origin),
         do: {:ok, %Island{type: type, coords: coords, hits: MapSet.new()}},
         else: ({:error, _reason} -> {:error, :invalid_island_args})
  end
  def guess(%Island{} = island, %Coord{} = guess) do
    if MapSet.member?(island.coords, guess),
      do: {:hit, update_in(island.hits, &MapSet.put(&1, guess))},
      else: :miss
  end

As you can see above, the do: and else: clauses are more indented for with than for if.
And I understand why but it just struck me.

Thanks

1 Like