3 ms·
In ruby you can ensure this by calling responds_to?(:method). So for example to see if some object is iterable, you just check if it responds to each. obj.
by nudded 17y ago
In ruby you can ensure this by calling responds_to?(:method).
So for example to see if some object is iterable, you just check if it responds to each.
obj.responds_to?(:each)
- jrockway 17y agoThat doesn't guarantee that "each" is actually the right "each".