Otherwise if the object only has the defaultrespond_to? method, its tries to call method_missing. NoMethodError is rescued and taken to mean that the object does not respond to to_ary, and the object is not flattened.
Without a NoMethodError it means the object effectively responds to to_ary, and the return type must be Array.
a=Object.newdefa.method_missing(...);42;end[a].flatten#=> TypeError (can't convert Object to Array (Object#to_ary gives Integer))defa.method_missing(...);[[42]];end[a].flatten#=> [42]defa.method_missing(...);super;end#NoMethodError triggered via super[a].flatten#=> [#<Object:0x00005603341f3b18>]defa.method_missing(...);42.foobar;end#NoMethodError is actually because of foobar[a].flatten#=> [#<Object:0x0000560334024300>]