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 trialGlenn Rudge
741 PointsGetting contextual errors on tongueLength bool return method.
Error: The name `ToungueLength' does not exist in the current context Compilation failed: 1 error(s), 0 warnings
Thanks in advance for the help.
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
public bool EatFly(int distanceToFly)
{
if (ToungueLength == distanceToFly)
{
return true;
}
else
{
return false;
}
}
}
}
2 Answers
Simon Coates
8,377 PointsIt looks like a spelling error with the line
if (ToungueLength == distanceToFly)
But the condition is also wrong. The frog can also eat flies closer than the length of its tongue. So the test should be if tongueLength exceeds or is equal to distanceToFly.
Glenn Rudge
741 PointsThanks for the help, that slipped my mind.
I sometimes get confused with method parameters and variables. I'm working on that though. Cheers!