• Post Reply Bookmark Topic Watch Topic
  • New Topic

return statement required  RSS feed

 
Ricky James
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have written a simple method that returns the name passed and an int variable that counts the no. of visits.

When I try to compile this it give me an error saying that a "return statement is required".

Would be thankful if somebody advised me how I may resolve this issue.



Thanks
Ricky
 
Kel Michaels
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must have a return value. Because all of your returns are wrapped in if blocks you do not have a guaranteed return.

Refactor your code to return a value at the end of the method. So in your if blocks you set the string you want to return to some variable.

 
Ricky James
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kel Michaels:
You must have a return value. Because all of your returns are wrapped in if blocks you do not have a guaranteed return.

Refactor your code to return a value at the end of the method. So in your if blocks you set the string you want to return to some variable.



Thanks a lot Kel.

That resolved the issue.

Really appreciated.
Ricky
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!