有没有办法在 D 范围内创建一个步骤? 例如,在 python 中, 范围(1、10、2) 给我
[1, 3, 5, 7, 9]
1 .. 10 以内的所有赔率
有没有办法在 D 中使用 foreach 来做到这一点?
foreach(x; 1 .. 10) {
}
我知道我可以使用 iota(start, end, step),但我也想在最开始添加一个 int,但我不知道如何将类型 Result 转换为 int。
最佳答案
关于iteration - 步进 D 中的范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17244195/