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 trialSahar Nasiri
7,454 PointsA function is the first object of a class!
I didn't get this! We have to build an object which is an instance of a class and that's the object of a class! How is that a function of a class is the object of that class?
2 Answers
Kourosh Raeen
23,733 PointsHi Sahar - It basically means that you can use functions in ways similar to how objects are used:
You can pass a function as an argument to another function, much like passing an object to a function.
You can have a function return another function, just like a function returning an object.
Just like objects, functions can have attributes.
Steven Parker
231,236 PointsI'm not sure you're using the correct terminology. Do you perhaps mean that the "function is a method of the class"?
Or are you talking about where a "function is a first-class object"?
Sahar Nasiri
7,454 PointsKenneth said "Another part that's important about all of this process is that functions are known as first class citizens or first class objects." in this video on 3:03
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsMy kingdom for a hyphen...
The quote should be "Another part that's important about all of this process is that functions are known as first-class citizens or first-class objects."
The quality term first-class has nothing to do with the term
class
which is an object type.