Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Siu KWAN Yuen](https://secure.gravatar.com/avatar/e2f80ab0b98bbf45516eb1bdec049fdc?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Siu KWAN Yuen
Courses Plus Student 2,898 Pointsassign new value to field using method
In this lesson, I saw Craig uisng the getCurrentProgress method to check out if the guess matches the answer, and show them the letter if it is matched. But why do we declare "String progress", the value returned by the method, inside the method. Wouldn't we lost the "String progress" after the method is called?
2 Answers
![Peter Danglay](https://secure.gravatar.com/avatar/9b52d751242c675bb51d5651eefa7611?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Peter Danglay
861 PointsI might be wrong but this is how I understand it in the code it will call the method and get the value of the value it returned
![Siu KWAN Yuen](https://secure.gravatar.com/avatar/e2f80ab0b98bbf45516eb1bdec049fdc?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Siu KWAN Yuen
Courses Plus Student 2,898 PointsYa, but you cannot game.stringProgress it or game.getProgress it.
![Peter Danglay](https://secure.gravatar.com/avatar/9b52d751242c675bb51d5651eefa7611?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Peter Danglay
861 PointsIs the code you are talking about?
public boolean isWon(){
return getCurrentProgress().indexOf('-') == -1;
}
if it is this is how it works it will get the value of the method whatever is returned and check to see if it does not contain '_' if it doesn't contain it gives true if it does contain it will give false.
Peter Danglay
861 PointsPeter Danglay
861 PointsDon't take my word for it