From: grady@... (Steven Grady) Date: 2000-12-02T04:40:05+09:00 Subject: [ruby-talk:6714] Re: behavior of Proc#arity? Matz responds: >In message "[ruby-talk:6682] behavior of Proc#arity?" > on 00/12/01, Steven Grady writes: > >| || >| |a| >| |*a| >|return -1, while there is nothing that returns 0 or 1? > >They accept any number of arguments without causing error, thus their >arity must return -1. |a| is something like compromised |*a|, which I >mean it's almost identical to |*a|, but since it appears to accept >just one argument, it treats single argument specially. Ah. That would certainly explain the behavior of Proc#arity (and maybe even justify it :-). Is it documented anywhere? The closest I can find is the statement (in The Book) that "Parameters passed to the will be assigned to arguments in the block using the rules of parellel assignment". But there is no such thing as "parallel assignment" for a single variable, so I think that passage does not explain things. (BTW, should do the same magic as ? Right now, it generates a parse error.) I don't see any examples of using the |a| behavior, that is, to do anything different from the |a,| behavior. Do people actually rely on the current, flexible semantics? Also, what is the meaning of ||? According to my tests, it allows you to pass 0 or more arguments, just as with |a|. Is there anything special it does? Is different from ? I assume there is no way to produce a proc of arity 0? Sorry for all the questions -- just trying to understand this new and wonderful language. -- Steven "Hey, stewardess. Run through that seatbelt demonstration a few more times. It's unbelievably tricky!"