From: Tobias Reif Date: 2002-01-28T08:06:42+09:00 Subject: Re: how to find out which args a method can take Dave Thomas wrote: > Tobias Reif writes: > >>I know that I can pass wide varieties to some methods. What I thought >>was: perhaps there are any built-in documentation like info bits that >>can help whan generating "tests" for built-in methiods. Something like >>Array.works_with_args?('join') # -> [[String]] >>String.works_with_args('sub') # -> [[Regex,String], [Regex, Block]] >>String.works_with_args('reverse') # -> [] >> > But... Ruby classes are not types in this sense Is the above depending on this? I don't get what you mean :| A human can see what built-in methods can take by looking @ documentation like sub str.sub( pattern, replacement ) -> aString str.sub( pattern ) {| match | block } -> aString So now I would like my program to be able to get the same information (as far as possible) from perhaps some class method. > (although admittedly > it works 99% of the time). For example, > > irbsh(main):001:0> e = Exception.new("hello") > # > irbsh(main):002:0> "123".sub(/./, e) > "hello23" Could you be so kind and explain the above to me? > You _could_ find out some of the information you need by trying things > and catching the TypeError exception, but that seems like a lot of > work :) ... or a lot of fun? :) Nah. I'd like to ask the method. Tobi -- http://www.pinkjuice.com/