develooper Front page | perl.perl5.porters | Postings from September 2016

Re: Not sure if this is a bug or not: Ranges and integer arithmetic

Thread Previous
From:
Sergey Zhmylove
Date:
September 1, 2016 13:10
Subject:
Re: Not sure if this is a bug or not: Ranges and integer arithmetic
Message ID:
de4f2362-070d-0c0d-b9e7-100344cbb76b@Tune-IT.ru
Such strange behavior of "~" operator (implicit signed integer context) 
seems to be also in slices and array indexes:

$ perl -le '@arr=1..5; print @arr[~1]'
4
$ perl -le '@arr=1..5; print $arr[~1]'
4

Kind regards,
Sergey Zhmylove.


31.08.2016 3:58, Father Chrysostomos wrote:
> Matt S Trout wrote:
>> THis seems inconsistent at best, but I wasn't sure exactly what to report.
> It is inconsistent.  I think it is a bug.  But deciding how it should
> behave is the hard part.  Can we change it without breaking peo-
> ple's code?
>
> I suppose the way to change it without breaking people's code is to
> make foreach match the dotty behaviour.


Thread Previous


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