• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why is the error "missing return statement"

 
Varuna Seneviratna
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator





The TestDrive has the "main"
When the return statement is included why do I get the error "Missing return statement".Is there a particular place where the return statement should be situated.


Varuna
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The checkUserGuess does not in all cases return something. If the locationCells array is empty, no return statement is ever reached.
 
ruban raj
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to place return statement out of "for loop" in side of checkUserGuess() method.

Thanks and regards,

Vasiammal.p
 
Campbell Ritchie
Sheriff
Pie
Posts: 49372
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ruban raj:
You have to place return statement out of "for loop" . . .


Agree. In fact the return statements, if they are actually executed, will break the repetition by terminating the loop.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic