songyy
songyy

Reputation: 4563

Knowing default parameter value

I have a method definition like this:

def m1(a:Int, b:String, c:Val)                                                 
end

m = method(:m1) 

Note that Int, String, Val are default values for a, b, c.

Is it possible to get this information from the method object m?

Upvotes: 2

Views: 52

Answers (1)

Jörg W Mittag
Jörg W Mittag

Reputation: 369458

No, this is not possible. It has been discussed numerous times on the ruby-core mailinglist, but it's simply not feasible. What should your proposed method return for something like this:

def m(p: if rand < 0.5 then Time.now else ENV['HOME'] end) end

Upvotes: 1

Related Questions