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 trialAlfredo Prince
6,175 PointsCan someone help me with this code? I'm somewhat lost!
why is it telling me this? Make sure you add a return value to the detailsKitchen method.
I'm pretty sure that's what I did. Did I pass the parameters incorrectly?
<?php
class Render {
public static function displayDimensions($size)
{
return $size[0] . " x " . $size[1];
}
public static function getDimensions($room)
{
return $size->room;
}
public static function detailsKitchen($room)
{
return self::getDimensions($room);
}
}
1 Answer
Simon Coates
28,694 Pointsfollowing code passes:
<?php
class Render {
public static function displayDimensions($size)
{
return "{$size[0]} x {$size[1]}"; //odd syntax, but just concatenation
}
public static function detailsKitchen($room){
return "Kitchen Dimensions: ". self::displayDimensions($room->getDimensions());
}
}
?>
The key feature is that you are meant to call getDimensions on the room variable, which is an object.
Alfredo Prince
6,175 PointsAlfredo Prince
6,175 PointsSimon, Thank you. But could you please elaborate why what I did was wrong? I would really appreciate it.
Simon Coates
28,694 PointsSimon Coates
28,694 PointsThe problem was that you are meant to call getDimensions on $room. The room object is of a class that has a getDimensions method already defined. It returns an array, which is used as the argument for the static displayDimensions method. And you need to concatenate with "Kitchen Dimensions: " to produce the requested string.
Alfredo Prince
6,175 PointsAlfredo Prince
6,175 PointsI see it now! thank you!