What does the [] operator do here?
Net
netorib94 at gmail.com
Wed Apr 1 19:35:30 UTC 2020
from the below code, the expression "case [c]":
void main()
{
import std.stdio, std.string, std.algorithm, std.conv;
// Reduce the RPN expression using a stack
readln.split.fold!((stack, op)
{
switch (op)
{
// Generate operator switch cases statically
static foreach (c; "+-*/")
case [c]:
return stack[0 .. $ - 2] ~
mixin("stack[$ - 2] " ~ c ~
" stack[$ - 1]");
default: return stack ~ op.to!real;
}
})((real[]).init).writeln;
}
More information about the Digitalmars-d-learn
mailing list