-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
I found this to be very useful, but I don't know if it's in line with your overall strategy.
Explanation: When using relations, a "many" reference (e.g.: has_many, embeds_many) initializes as an empty array, which allows you to use array-specific methods (e.g.: Array#<<) with no worries. This behavior is nice. When defining a regular field of type Array, it initializes as nil, so if you're not sure whether the array already has elements in it, then you can't use array-specific methods without first testing whether it actually is an array. A similar argument applies to operating on fields of type Hash. This update just sets Array and Hash fields as "empty" instead of nil.