Hi -- On Mon, 15 Nov 2004, Sam Roberts wrote: > Quoteing dblack / wobblini.net, on Mon, Nov 15, 2004 at 09:00:18AM +0900: > > > I'd like to mix a little bit more of Array into Struct! > > > > You can do that (just write a module and extend your Structs), though > > in general I think Structs are more hash-like than array-like. If > > there's a #[] method, I wouldn't expect it to be restricted to > > integers. (Is the order of #to_a for Structs even guaranteed?) > > Aha, so I expected it be more like an Array, and you expected it to be > more like a Hash! But, it is not quite either. :-) I agree; ultimately I expect it to act like a Struct :-) > > (Tangential question: > > > > How does one refer to the methods one defines on a Struct, or for that > > matter its other instance methods? The usual ClassName#method_name > > thing doesn't work :-) > > The thing Struct.new returns is enough of a class, isn't it? > > irb(main):001:0> s = Struct.new('MyClass', :foo, :bar) > => Struct::MyClass > irb(main):002:0> s.methods > => ["send", "name", "display", "class_eval", "object_id", What I meant was referring to a method in writing, the way we say Array#push or String#split. David -- David A. Black dblack / wobblini.net