From: Andrew Wagner Date: 2010-08-30T22:33:55+09:00 Subject: Re: Pass an array to a new instance of a class. --0016e6dd8bf2f6a8d4048f0a8378 Content-Type: text/plain; charset=UTF-8 If I'm understanding right, the modifications I made to your code below should do what you want On Mon, Aug 30, 2010 at 9:21 AM, Jonathan Allen < jonathan.allen@insightbb.com> wrote: > I am having trouble passing values to an array of a new instance of the > class Item that I have created. The following codse does not fille the > flags array with the value 'container'. > > > class Item > attr_accessor :inum, :name, :description, :slot, :flags, :items > > def initialize( inum, name, description, slot, flags, items ) > @inum = inum > @name = name > @description = description > @slot = slot > @flags = flags > @items = items > end > > def is_container > return true if flags.include?(container) > end > end > > > Item.new("0007", "crate", "A large crate.\r\n", ":none", ["container"], > []) > > > However when I use the code below, I am able to add the value > 'container' to the flags array. > > > $rooms[("0001")].item("crate").flags << "container" > > > My question is, how do I modify the first bit of code to allow passing > values to the array of the new instance of the class Item? > -- > Posted via http://www.ruby-forum.com/. > > --0016e6dd8bf2f6a8d4048f0a8378--