This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Weird parts of Java

 
Saloon Keeper
Posts: 11506
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm with Winston.

I love putting returns statements wherever it helps me avoid block statements. If you're eyeballing through a piece of code, you're making mental notes of execution paths the runtime can take. You eliminate execution paths by using return/break/continue statements, so it eases the mental gymnastics you have to do.
 
Marshal
Posts: 68148
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely it'sThat avoid returning null unnecessarily.
 
Stephan van Hulst
Saloon Keeper
Posts: 11506
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree, and that's what I wrote at first, but I changed it this way to make the two snippets more similar (and to avoid an else-statement). Maybe it was a bad example.

Returning null is rarely a good thing.
 
Could you hold this kitten for a sec? I need to adjust this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!