• Post Reply Bookmark Topic Watch Topic
  • New Topic

Missing return statement  RSS feed

 
Dale Herring
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,
I am trying to return an array from a simple method but can't figure out why it's throwing a "missing return statement error". Have I gone blind?

 
Tim Moores
Saloon Keeper
Posts: 4023
94
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The return statement is currently inside the loop - it should be outside (after) the loop.
 
Campbell Ritchie
Marshal
Posts: 56522
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
You would have found the error for yourself if you had indented the code properly. If the array passed to that method has a length of 0, then the loop will never start, and the return statement will never be reached.
 
Dale Herring
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks brosef
 
Campbell Ritchie
Marshal
Posts: 56522
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a pleasure
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!