[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02655] Re: Append alias for Array.append?

From: Aleksi Niemel<aleksi.niemela@...>
Date: 2000-05-09 09:12:35 UTC
List: ruby-talk #2655
In message "[ruby-talk:02651] Append alias for Array.append?"
    on 00/05/09, Aleksi Niemel<aleksi.niemela@cinnober.com> writes:

> |Some reason there's no Array.append? Or, let me rephrase, should there
exist
> |append as an alias to push.
Matz:
>Python's append works like this.
>  a = []
>  a.append(1,2,3)
>  a  #=> [(1,2,3)]
>Do you think it's OK for append to be alias to push?

I'm not educated on this, but I think the way it works on Python is probably
normal, just not for me :).

  a = []
  a.append(1,2,3)    #=> [1,2,3]
  a.append([4,5,6])  #=> [1,2,3,[4,5,6])

This is probably what I expect from Ruby. 

I guess what's Python is doing is to make a call to append giving it an
argument which is tuple. Which in turn is generated auto*magically* from the
argument list. This was just a guess, because I don't know.

I think clearer Python version should be a.append((1,2,3)) clearly
expressing the tuple creation, but once the append doesn't take multiple
arguments this autoconversion from multiple arguments to one tuple is quite
straight-forward.

Since we don't have tuples (do we?) and the magic part might be confusing,
my vote goes for this version with multiple arguments like push (now :).

	- Aleksi

In This Thread

Prev Next