I just want to check I've not missed something here. Is there a built-in
way to initialize a Struct from a hash of key/value pairs?

That is, can I shorten the following?

K1 = Struct.new :foo, :bar

module FixStruct
  def set(h)
    h.each { |k,v| self[k] = v }
    self
  end
end

class K1
  include FixStruct
end

k1 = K1.new.set(:bar=>456, :foo=>123)
p k1

(I'm talking about real Struct here, not OpenStruct etc)

Thanks,

Brian.

-- 
Posted via http://www.ruby-forum.com/.