The class (non-structural) has a simpler tree of ancestors:
>> Fruit.ancestors => [Fruit, Object, Kernel, BasicObject]
Compared to the structure version:
>> Fruit.ancestors => [Fruit, #<Class:0x1101c9038>, Struct, Enumerable, Object, Kernel, BasicObject]
Thus, the Struct class could be mistaken for an array (rarely, but absolutely can happen)
fruit = Fruit.new("yo") # .. later fruit.each do |k| puts k end # outputs: yo
So ... I use Structs as data drop objects. I use "real" classes in my domain and application.
Jesse wolgamott
source share