struct.rb:
  #!/usr/bin/env ruby
  class User < Struct.new(:screenname, :password)
    def initialize(sn, pw)
      self.screenname = sn
      self.password = pw
    end
    def inspect
      self.values
    end
  end

in IRB:
  Ruby> irb -r struct.rb
  irb(main):001:0> myusr = User.new "c00lryguy", "pass"
  => c00lryguypass            #Returns as an array as a string
  irb(main):002:0> myusr.values
  => ["c00lryguy", "pass"]    #Returns as an array
  irb(main):003:0> myusr
  => c00lryguypass            #Again, returns as an array as a string




Now, why doesn't the inspect method return as an array?
-- 
Posted via http://www.ruby-forum.com/.