dwyl / mvp

📲 simplest version of the @dwyl app
https://mvp.fly.dev
GNU General Public License v2.0
87 stars 2 forks source link

Update `get_person_id` #134

Closed SimonLab closed 2 years ago

SimonLab commented 2 years ago

The if/else statement is bothering me in:

  defp get_person_id(assigns) do
    if Map.has_key?(assigns, :person) do
      assigns.person.id
    else
      0
    end
  end

We can instead use:

defp get_person_id(assigns), do: assigns[:person][:id] || 0

If assings.person is not defined then assigns[:person][:id] returns nil

I find this easier to read

nelsonic commented 2 years ago

Agreed. Much cleaner. Thanks.