Ruby で method_missing が呼び出されている戻り引数の数を知りたいです。生成するはずの戻り引数の数に応じて、関数の動作を変更したいと思います。nargout
Matlabで同等のものを探しています。この例では XXX:
class Test
def method_missing(method_id, *args)
n_return_arguments = XXX
if n_return_arguments == 1
return 5
else
return 10, 20
end
end
end
t = Test.new.missing_method # t should now be 5
t1, t2 = Test.new.missing_method # t1 should now be 10 and t2 should now be 20