Closed SimonLab closed 2 years ago
The if/else statement is bothering me in:
if/else
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
assings.person
assigns[:person][:id]
nil
I find this easier to read
Agreed. Much cleaner. Thanks.
The
if/else
statement is bothering me in:We can instead use:
If
assings.person
is not defined thenassigns[:person][:id]
returnsnil
I find this easier to read