View Single Post
Old 01-31-2021, 05:02 PM   #29
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,591
Karma: 14328510
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by andyh2000 View Post
...
Andrew
A mentor of mine once told me that a mentor of his said it can be useful to get rid of nested if else statements when you can because it can make the code less convoluted. So take this with a grain of salt. For example,
Code:
if current_state == 0:
    set_lights_green()
    return

if current_state == 1:
    set_lights_red()
    return

set_lights_blue()
But often the code doesn't lend itself to this treatment.
hobnail is offline   Reply With Quote