Why struct? Not Hash or OpenStruct?
When we want to store the key value pair most of them prefer Hash, because that is how we learned from the basic. But in real time compare to Hash and Openstruct, Struct works better than other key value storage… Find the useful arcticle http://bit.ly/1hWI1aM
Comments
Real time compare to Hash and Openstruct, Struct works better than other key value storage in #ruby.
I’d personally also freeze the response, since a result is presumably immutable.
I think Struct is great for when you know exactly what parameters you’re going to get. For when you don’t, OpenStruct or Hashes (with Indifferent Access) are better, in my opinion. You can also chuck a hash into an OpenStruct and get methods that way.
Post a comment