【发布时间】:2013-03-01 11:28:33
【问题描述】:
我想在编译时加入文件名和图像格式。
以下示例不起作用,因为我想在编译时无法评估 string[]...
immutable imageFormats = ["bmp", "jpg", "gif", "png"];
template fileNamesWithImageFormat(string[] fileNames)
{
string[] fileNamesWithImageFormat() {
string[] ret;
ret.length = imageFormats.length * fileNames.length;
for (int j = 0; j < fileNames.length) {
for (int i = 0; i < imageFormats.length; ++i) {
ret[j * fileNames.length + i] = fileNames[j] ~ "." ~ imageFormats[i];
}
}
return ret;
}
}
失败并显示错误消息:
Error: arithmetic/string type expected for value-parameter, not string[]
我需要将其最终输入import()。错误如何解决?
【问题讨论】: