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

help

Instantiate a new instance of the Array class and assign the newly instantiated instance to the variable array.

my code:

string = String.new("a random string")

http://teamtreehouse.com/library/ruby-objects-and-classes/ruby-objects-and-classes/instantiation-2

4 Answers

part 1 answer is

string = String.new
string= String.new

Part 2 answer is

string = String.new
array=Array.new

you can instantiate an array similar to the way you instantiated a string. use the new method of the Array class. it takes an argument that is the size of the array or you can leave it out:

array = Array.new(3);
array2 = Array.new
array=Array.new