[Issue 1202] New: Dollar inside array literal inside index brackets is valid.
Daniel Keep
daniel.keep.lists at gmail.com
Sun Apr 29 17:31:13 PDT 2007
d-bugmail at puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1202
>
> Summary: Dollar inside array literal inside index brackets is
> valid.
> Product: D
> Version: 1.014
> Platform: PC
> OS/Version: Linux
> Status: NEW
> Severity: trivial
> Priority: P4
> Component: DMD
> AssignedTo: bugzilla at digitalmars.com
> ReportedBy: aziz.kerim at gmail.com
>
>
> // writefln([1,2,$]); // '$' is valid only inside [] of index or slice
> writefln([1,2,3][0 .. [$][0]]); // [1,2,3]
> writefln([1,2,3][0 .. [0,$][1]]); // [1,2,3]
> writefln([1,2,3][0 .. [0,1,$][$-1]]); // [1,2,3]
> writefln([1,2,3][0 .. [0,1,$][$-$]]); // []
> writefln([1,2,3][0 .. [$][$-$]]); // [1,2,3]
> writefln([1,2,3][0 .. $*[$][0]/$]); // [1,2,3]
> writefln([1,2,3][0 .. [$,[$][0]][0..$][0]]); // [1,2,3]
ZOMG! That's awesome! I vote we keep this if only to confuse the hell
out of people with it! :)
-- Daniel
--
int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
http://xkcd.com/
v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
More information about the Digitalmars-d-bugs
mailing list