Created
November 29, 2017 16:34
-
-
Save reox/1010778e5727d99445301b9834d27c95 to your computer and use it in GitHub Desktop.
divide by a value, decide with a flag
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
# What you would normaly do: | |
def some_divison(): | |
flag = True | |
val = 23 | |
divisor = 42 | |
if flag: | |
return val / divisor | |
# Now the method without if: | |
def new_divison(): | |
flag = 1 | |
val = 23 | |
divisor = 42 | |
# if flag == 1, the division will run. If flag == 0, val is returned | |
return val / divisor ** flag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment