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 Ruby Objects and Classes Ruby Objects and Classes Instantiation

Think it's bugged. Tried Array.new(), Array.new[], Array.new(array), Array.new[array], array = Array.new. Still stuck.

I think this question is bugged. I've tried multiple different ways to start a new array (some I'm sure are even right, ha!) and it keeps giving the error message about using the new String method.

5 Answers

It's asking you to instantiate a new instance of the Array class called array. So it wants array = Array.new.

I can see why you would be confused though, throwing the word array in there automatically makes you think it needs some brackets.

I think that it is just "array.new"

you don't need to put the parenthesis at the end

Hi Jim,

No it is not bugged, I even tried to test it as it is passed. :)

String # 1

variable = string

class = String

method = new


Array # 2

variable = array

class = Array

method = new


Example:

string = String.new
array = Array.new

The answer to the first question in the Code Challenge is:

string = String.new

You probably knew that already, right? Well, when you answered the next question, you probably deleted the first answer. Don't - leave it there and add your answer underneath the first one. The complete code challenge will look like this:

string = String.new
array = Array.new

Wow, this one feels especially...picky, ha. Thanks everyone for your help!