shift/unshift

This commit is contained in:
Mark Pilgrim
2009-07-22 21:16:12 -04:00
parent 1ec34b319f
commit 1f0411293c
+1 -1
View File
@@ -292,7 +292,7 @@ ZeroDivisionError: Fraction(0, 0)</samp></pre>
</ol>
<blockquote class='note compare perl'>
<p><span class=u>&#x261E;</span><code><var>a_list</var>.insert(0, <var>value</var>)</code> is like the <code>shift()</code> function in Perl. It adds an item to the beginning of the list, and all the other items have their positional index bumped up to make room.
<p><span class=u>&#x261E;</span><code><var>a_list</var>.insert(0, <var>value</var>)</code> is like the <code>unshift()</code> function in Perl. It adds an item to the beginning of the list, and all the other items have their positional index bumped up to make room.
</blockquote>
<p>Let&#8217;s look closer at the difference between <code>append()</code> and <code>extend()</code>.