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 trialBong Oh Park
3,083 PointsCan you figure out the cause of error in my coding?
Please explain to me why parameter declaration for distanceToFly is not working.
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog(int tongueLength)
{
TongueLength = tongueLength;
}
public EatFly()
{
public int distanceToFly;
bool result;
if (distanceToFly < TongueLength)
{
return result = true;
}
else
return result = false;
}
}
}
1 Answer
Umesh Ravji
42,386 PointsHi Bong, parameters are declared inside the brackets after the method name. You must also include the return type before the method name (or void if there is none).
public bool EatFly(int distanceToFly) {
// method body
}
Bong Oh Park
3,083 PointsBong Oh Park
3,083 PointsThank you, Umesh Now I got clear understanding on parameter declaration thanks to your explanation.