J
Jonathan Allen
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 = []
@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?
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 = []
@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?