Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!