I have a script in which I was using a 2-element array where a struct
would be used in another language, so I decided to give the Ruby class
Struct a try.
My script went from taking 2 seconds to taking 27 seconds from this
simple change! The use of this 2-element array is only one small part
of the script so it was very surprising to me that it could even cause
the script to take twice as long no matter how inefficient it might be.
To take more than 10 times longer for the entire script to execute was a
I will probably shy away from the use of the Struct class after this
brief experience and use arrays with constants for the indexes. I’m
wondering if this is an erroneous conclusion and perhaps I am missing
What are the advantages/disadvantages of using the Struct class in Ruby?