-
-
Save chrisza4/2278c8329ea349a29b8a265ed86dad0c to your computer and use it in GitHub Desktop.
So many nil check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Assuming get(id) is database hit, so we don't want to hit database for everything up-front | |
| def some_func(id1, id2, id3) do | |
| if EntityA.get(id1) == nil do | |
| {:error, :not_found} | |
| else | |
| if EntityB.get(id2) == nil do | |
| {:error, :not_found} | |
| else | |
| if EntityC.get(id3) == nil do | |
| {:error, :not_found} | |
| else | |
| # Start do something | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment