treyhunner,
@treyhunner@mastodon.social avatar

So before you remove that "else" statement, think about whether it makes your code more readable or not.

Read more 👉 https://trey.io/FlSco3

flowchainsenseisocial,

@treyhunner Also, reject all "if" statements.

bugroar,
@bugroar@techhub.social avatar

@treyhunner I suppose "return date1 if blah else date2" is out of the question?

treyhunner,
@treyhunner@mastodon.social avatar

@bugroar It's an option! Though in this case the "blah" would be pretty long.

henrikjernevad,
@henrikjernevad@mastodon.social avatar

@treyhunner @bugroar Nice post! I thought about this case too. In some languages (e.g. Kotlin) the regular "if statement" is in fact an expression. So then you could have return if (condition) { expression } else { expression } where { expression } can be any number of statements as long as the last one is an expression. This style further highlights the importance of the else branch as removing it would break the expression.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • PowerRangers
  • DreamBathrooms
  • osvaldo12
  • magazineikmin
  • InstantRegret
  • everett
  • Youngstown
  • ngwrru68w68
  • slotface
  • rosin
  • GTA5RPClips
  • tester
  • kavyap
  • thenastyranch
  • provamag3
  • mdbf
  • ethstaker
  • cisconetworking
  • Durango
  • vwfavf
  • normalnudes
  • tacticalgear
  • khanakhh
  • modclub
  • cubers
  • Leos
  • anitta
  • megavids
  • All magazines