Is there a way to access method arguments in Ruby?

后端 未结 11 1127
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 17:00

New to Ruby and ROR and loving it each day, so here is my question since I have not idea how to google it (and I have tried :) )

we have method

def f         


        
11条回答
  •  误落风尘
    2020-11-29 17:58

    One way to handle this is:

    def foo(*args)
        first_name, last_name, age, sex, is_plumber = *args
        # some code
        # error happens here
        logger.error "Method has failed, here are all method arguments #{args.inspect}"    
    end
    

提交回复
热议问题