Created
October 25, 2019 09:01
-
-
Save wolframkriesing/a648b085dc634b47a7c03c8386dbe829 to your computer and use it in GitHub Desktop.
using braces to limit scopes
This file contains 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
const findUser () => { | |
{ | |
const userOrError = findUserInCache(); | |
if (userOrError instanceof Error) return userOrError; | |
if (userOrError instanceof User) return userOrError; | |
} | |
{ | |
const userOrError = findUserInDb(); // reusing `userOrError` inside the same fn | |
if (userOrError instanceof Error) return userOrError; | |
if (userOrError instanceof User) return userOrError; | |
} | |
return new NoUser(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment