develooper Front page | perl.perl6.users | Postings from December 2017

++ mutable argument problem

Thread Next
From:
Mark Senn
Date:
December 14, 2017 14:39
Subject:
++ mutable argument problem
Message ID:
42086.1513136501@pier.ecn.purdue.edu
# I define
my @dice =
(
    # type        pips on first die   pips on second die  tally
    ('normal',    (1, 2, 3, 4, 5, 6), (1, 2, 3, 4, 5, 6), 0 xx 14),
    ('Sicherman', (1, 3, 4, 5, 6, 8), (1, 2, 2, 3, 3, 4), 0 xx 14)
);
# and later do
@dice[1;3;2]++;
# and get
#     Cannot resolve caller postfix:<++>(Int); the following candidates
#     match the type but require mutable arguments:
#         (Mu:D $a is rw)
#         (Int:D $a is rw)
#
#     The following do not match for other reasons:
#         (Bool:D $a is rw)
#         (Bool:U $a is rw --> Bool::False)
#         (Mu:U $a is rw)
#         (Num:D $a is rw)
#         (Num:U $a is rw)
#         (int $a is rw)
#         (num $a is rw --> num)
#       in block <unit> at ./t.p6 line 13
#
# I want to keep the array structure for the data.
# What's the cleanest solution.  Thanks.    -mark

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About