From: "matz (Yukihiro Matsumoto)" Date: 2012-04-10T18:48:46+09:00 Subject: [ruby-core:44261] [ruby-trunk - Feature #4862][Rejected] Struct#to_hash Issue #4862 has been updated by matz (Yukihiro Matsumoto). Status changed from Assigned to Rejected #to_hash protocol expects the object to be hash-compatible. Struct is not the case. Matz. ---------------------------------------- Feature #4862: Struct#to_hash https://bugs.ruby-lang.org/issues/4862#change-25798 Author: postmodern (Hal Brodigan) Status: Rejected Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: Occasionally, it is necessary to convert a Struct to a Hash (especially when generating JSON from an Array of Structs). A Struct#to_hash method would be very useful in this situation. class Struct # # Returns the Hash representation of the members and values within the struct. # def to_hash new_hash = {} each_pair do |member,value| new_hash[member] = value end new_hash end end -- http://bugs.ruby-lang.org/