next-ls icon indicating copy to clipboard operation
next-ls copied to clipboard

workspace command: convert an if into a cond

Open mhanberg opened this issue 2 months ago • 0 comments

A workspace command that converts an if expression into a cond expression

Example:

defmodule Example do
  def run(foo) do
    if foo do
      :ok
    else
      :error
    end
  end
end

Using the workspace command on the if keyword of the expression will result in:

defmodule Example do
  def run(foo) do
    cond do
      foo ->
        :ok
      true ->
        :error
    end
  end
end

Consider the following:

  • Inline if/else statements (keyword arg verisions

mhanberg avatar Apr 30 '24 12:04 mhanberg