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 trial
Derek Medlin
6,151 Pointsarray.count vs [array count]
I know they are the same but is there a reason why 99.99% of the people use brackets vs the dot notation (EDIT: for the count of an array)? It might just be a coincidence but i'm just curious. Thanks.
2 Answers
Stone Preston
42,016 Pointsdot notation is converted to standard bracket syntax when compiled. Some people dont like using dot notation because its not explicit that a method is being called. but personally I find using dot notation easier so I use it quite a bit. especially when accessing properties since self.propertyName is much easier than writing [self propertyName]
Derek Medlin
6,151 PointsYeah, same here. Thanks for the quick reply, I figured there wasn't a reason other than just preference. It's just crazy that the people that use dot notation in like everything except for the count of array and stuff. Anyways, stupid question. Just was curious. thanks!
Stone Preston
42,016 PointsAlthough I pretty much use dot notation for properties and array counts and lengths of strings. Simple stuff like that. Other methods I usually use bracket.