Skip to content

Commit

Permalink
Implement << for Arrays; test included.
Browse files Browse the repository at this point in the history
  • Loading branch information
treed committed Jul 17, 2009
1 parent 4d319ce commit 295dd7b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/classes/Array.pir
Expand Up @@ -1206,6 +1206,22 @@ Operator form for either repetition (when argument is an Integer), or as a short
diff_done:
.return (array)
.end

.sub 'infix:<<' :multi('CardinalArray',_)
.param pmc this
.param pmc that
this.'push'(that)
.return (this)
.end

.sub 'infix:<<' :multi(_,_)
.param pmc this
.param pmc that
$P0 = new 'CardinalArray'
$P0.'push'(this)
$P0.'push'(that)
.return ($P0)
.end

=item C<infix:,(...)>

Expand Down
5 changes: 4 additions & 1 deletion t/array/mathop.t
@@ -1,6 +1,6 @@
require 'Test'
include Test
plan 13
plan 14

a = [ 1, 2 ]
b = [ 3, 4]
Expand Down Expand Up @@ -40,3 +40,6 @@ a = [1,3,5,7,8]
b = [1,5,8,9]
c = a & b
is c, [1,5,8], "Array & (union)"

a = [1,2] << "a" << 3 << [4,5]
is a, [1,2,"a",3,[4,5]], "Array <<"

0 comments on commit 295dd7b

Please sign in to comment.