Closed fanantoxa closed 7 years ago
@soulcutter Readed http://words.steveklabnik.com/beware-subclassing-ruby-core-classes article. But maybe we could override 'is_a' or 'kind_of' functions to check it? or it even worse idea?
99% of the time is_a?
or kind_of?
checks are not a good thing to do in Ruby. It's not idiomatic to do type checking where duck typing is the norm. With delegation you can still treat the object as an array, it just happens to wrap one to accomplish array-like features.
I definitely don't think overriding is_a?
or kind_of?
is a good idea.
On this commit https://github.com/soulcutter/saxerator/commit/220ac9bffad22c94a587e124e86622ba441dc26a#diff-9bea3d175ebbd6d9862278ff1d538242 You've change inheritance to delegation.
But users expect kinda simple elements lite String, Integer, Array and I think it's fair. so now to check that
ArrayEllement
is kinda Array we have to do:But it's not so usefull as
@soulcutter What do you think about it?