test169
auto test169 =
q{--- test169
// #foreach with multiple statements
@extern(module, "host")
void printStr(u8[]);
@extern(module, "host")
void printInt(i64 i);
$alias selectPrintFunc($type T) {
if ($isInteger(T))
return printInt;
if ($isSlice(T))
return printStr;
$compileError("Invalid type");
}
void write[Args...](Args... args) {
#foreach(i, arg; args) {
alias func = selectPrintFunc(Args[i]);
func(arg);
}
}
void run() {
write("Hello", 42);
}
};
tests passing
functionsvariables