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 trialThomas Newton
Courses Plus Student 2,442 PointsUse the constructor to initialize the TongueLength field to the value passed in.
I... have literally no idea what any of this means. Nothing in the previous video said what initializing was or explained how I would do this. Could somebody fill me in on what to do?
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog( int TongueLength){
TongueLength = TongueLength;
}
}
}
2 Answers
Chris M
592 PointsI solved it by doing this
namespace Treehouse.CodeChallenges
{
class Frog
{
public readonly int TongueLength;
public Frog (int tongueLength)
{
TongueLength = tongueLength;
}
}
}
you forgot to put some stuff in small caps.
change
public Frog( int TongueLength){
to
public Frog( int tongueLength){
and
TongueLength = TongueLength;
to
TongueLength = tongueLength;
You're using the "tongueLength" to initialize the TongueLength field. Don't feel too bad, you had the basic idea down.
Connor Swatling
Full Stack JavaScript Techdegree Graduate 21,148 PointsYou probably figured it out, but for whoever comes here later:
"Use the constructor to initialize the TongueLength field to the value passed in" is a poor way to word the question. Basically, the question is telling you to use the constructor you just build in the previous phase to automatically set a length without one being instantiated.
Simply change the line public Frog (int tongueLength)
to public Frog (int tongueLength = X)
where X is an integer.