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 trialpoltexious
Courses Plus Student 6,993 PointsDid Ben forget to add "return Pizza(toppings);" in orderPizza method in Example.java?
I just want to be sure if I am missing something, or if Ben forgot to return the Pizza object with input parameter(s) in the orderPizza method in Example.java?
public Pizza orderPizza(String toppings) {
// code to make the Pizza goes here
}
I mean, when one declares the return type with input parameter(s) in a method, should one not return it in the end of the method? Is there something wrong with my understanding, or should Ben write the following instead?
public Pizza orderPizza(String toppings) {
// code to make the Pizza goes here
return Pizza(toppings);
}
1 Answer
Ryan Farber
5,329 PointsYou are correct. I think he wanted to keep it simple rather than explain that part. Ben would have had to explain why he needed to return the topping, which would probably have added an unneeded minute or two to the video.
poltexious
Courses Plus Student 6,993 Pointspoltexious
Courses Plus Student 6,993 PointsOK. I just got confused that he did not include that piece of (important) information :-)