생성자의 매개 변수 이름을 검색하려고합니다. 다음 코드를 감안할 때 :생성자의 매개 변수 이름 얻기
class Something
def self.do_something(a, b); end
def initialize(a, b); end
end
내가 얻을 :
Something.method(:do_something).parameters
# => [[:req, :a], [:req, :b]]
Something.method(:new).parameters
# => [[:rest]]
왜 Method#parameters
는 new
의 경우 [[:rest]]
을 반환하고, 어떻게 생성자의 매개 변수를받을 수 있나요?
* + 1은 좋은 연구 ... –