Hi--

On Fri, 6 Nov 2009, Tony Arcieri wrote:

> On Thu, Nov 5, 2009 at 3:40 AM, Gavin Sinclair <gsinclair / gmail.com> wrote:
>
>>>   def ++
>>>     incrementing_logic_goes_here
>>>   end
>>>
>>> I could see this as being handy
>>
>> What's wrong with
>>
>>  def inc
>>     incrementing_logic_goes_here
>>  end
>>
>> How is that any different?
>>
>
> What's wrong with Array#push?  Why do we need Array#<<?  How is that any
> different?

irb(main):001:0> [].push(1,2,3)
=> [1, 2, 3]
irb(main):002:0> [].<<(1,2,3)
ArgumentError: wrong number of arguments (3 for 1)

:-) But I know that's not what you meant. The thing is, a method
called ++ that did in-place incremention would not be meaningful for
numbers (if I understand correctly that you mean it would be similar
to succ!), and having it for other objects would probably just lead to
more confusion. That's my hunch, at least.


David

-- 
The          Ruby training with D. Black, G. Brown, J.McAnally
Compleat     Jan 22-23, 2010, Tampa, FL
Rubyist      http://www.thecompleatrubyist.com

David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)