Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Creating the MVP Storing Guesses

Alexander Nowak
Alexander Nowak
498 Points

What does 'return isHit;' do? Why do we need it? and how do I know to use to in my code?

.

2 Answers

As you see the function applyGuess is public boolean, which means it returns a boolean value. isHit stores a boolean value an by using "return" you make sure the function returns that value.

Alexander Nowak
Alexander Nowak
498 Points

Returns that value to where?

Thanks!

It returns it to the code that invokes it. I am not sure of what the full code is because I couldn't see it but I see there is a true/false that gets printed in the console. I am however not sure if there is a print statement somwhere. For more info on what "return" does read this.