Re: Re: Support negative indexes for arrays and strings

From: Date: Tue, 04 Sep 2012 16:12:36 +0000
Subject: Re: Re: Support negative indexes for arrays and strings
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-62801@lists.php.net to get a copy of this message
Greetings. >> The main problem arises from the ambiguity for $array[-1] for arrays.>> But this is easily solvable: just introduce a slice operator. >> >> $array[:-1] and the ambiguity is gone. >That would return an array containing the last item as the sole member, >not the last item itself. Which suggests a solution, namely either use another symbol or else attach to the colon a different meaning. Or, we can forget about applying this feature to arrays and hope that users will understand that this is a feature that only applies to strings and use a simple negative offset.SL

« previous php.internals (#62801) next »