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

Ruby

2 Answers

Assuming an array called array:

array.length

or

array.size

array.count will only work on Will return the number of items in the array. For more info, check out the documentation on ruby arrays. Class: Array

Glad to help! I actually found out that there are three ways to do this. Array.length, Array.count, and Array.size. Here's a nice article that goes in to explaining what each method is, and why you would use it! Good for some morning reading:

The Elements of Style in Ruby #13: Length vs Size vs Count