Ok, so the following function returns an array, which is strange, because it should return an instance of the Item class. Using IRB I was able to make sure that each item in the @eq and @inv ARRAYS are in fact instances of the ITEM class. After calling the get_item method though, it returns an array containing an instance of the object. I can't seem to figure out why, any ideas?
def get_item(loc,name) if loc == :eq @eq.each do |item| if item.name.downcase.include? name.downcase return item end end elsif loc == :inv @inv.each do |item| if item.name.include? name return item end end end end
Does Ruby use any sort of special container class for iterators? I know with STL when iterating a list, you tend to have to dereference the iterator in order to directly access a pointer value. I could be way off though :P.
I'm not at home right now to test that out, but Stormy might well be right. Davion: You don't have to dereference the iterator in Ruby, it pretty much works just how I posted it, IF it's matching the item name. I didn't know Array#each returned an array otherwise, that's good to know. Thanks Stormy.
PS - Story, are you working on any kind of mud project in Ruby?