Re: I'm confused about Ruby.2.5.3 Method#arity for Dir.entries and Dir#entries
Colin Bartlett <[email protected]> Tue, 5 Nov 2019 15:09:29 +0000
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <CAKtK3JqFZRjFVyKKH6J0-nV4g+fPU1KtWNN5Xi494n8HVMd-Yg@mail.gmail.com> |
On Tue, Oct 22, 2019 at 1:15 PM gga <[email protected]> wrote: > ... > Looks like a couple of bugs to me. > That was what I thought, which was one reason I posted my question. But I think Frank J. Cameron's reply explains what's going on, so I now don't think it's a bug: I assume there's a good reason why "For methods written in C, returns -1 if the call takes a variable number of arguments.For methods written in C, returns -1 if the call takes a variable number of arguments". There are still the questions of why are there some differences between how Dir.entries behaves in Ruby and JRuby, and I'll think about that a bit more. In my reply to Frank J. Cameron I said that I now can't recall why I asked the question. I still can't recall it, but thinking about it a bit more it looks like I might be able to get the sort of information I was after by deliberately calling a method with zero arguments if it must have at least one argument, or with definitely too many arguments if it can have zero arguments, rescuing the exception, and then looking at the ArgumentError message. For example: Dir.entries() rescue v = $! puts v.to_s() #=> "wrong number of arguments (given 0, expected 1)" Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>