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 trialAbubakar Gataev
2,226 PointsHello could you help me please
I don't get what he has in the paratheses in Onmap. I think the first Point is for the class and I don't know what the second point is? please help me .
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! He's writing the parameters of the function. The function is named OnMap
and it takes one argument of type Point. Whatever instance of Point we send in will now be assigned to the local variable point
. The first word is the type. Now, this might be a little confusing at first because you're probably used to String
, int
etc. But by making a class you just made your very own type! So now, we say we're going to pass in an argument of type Point
and call it point
. The constructor method above it takes two arguments both of type int. One will be named width
and the other height
.
Hope this helps!
Abubakar Gataev
2,226 PointsAaah thanks a lot now I get it!
patric Iskevi
3,663 PointsGreat Jennifer, thanks for taking the time to clarify it to me!
patric Iskevi
3,663 Pointspatric Iskevi
3,663 PointsHi!
So the type Point has nothing to do with the Point class we created earlier? It is just the type we have created just for this particular method?
Cheers, Patric
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherHi patric Iskevi! Take a look at this quote from my previous answer:
Let's say that we make a new variable which is going to contain a new instance of our
Point
class namedmyPoint
. We then want to send that instance into a function. The function needs to be able to say what type the parameter is.For example:
In this simple example, we're declaring a method that prints out information about the point we're sending in. So given that we're sending in
myPoint
what should the type be? Int? String? Bool? No, ourmyPoint
is of typePoint
.Hope that clarifies things!