我想通过在http://dlang.org/library/std/array/by_pair.html在d使用byPair
给出的例子中工作,但我不断收到错误Error: no property 'byPair' for type 'int[string]'
有什么我需要进口,我不是?
import std.stdio;
import std.string;
import std.array;
import std.file;
import std.conv;
import std.regex;
import std.typecons : tuple, Tuple;
import std.algorithm : sort;
void main(string[] args)
{
auto aa = ["a": 1, "b": 2, "c": 3];
Tuple!(string, int)[] pairs;
// Iteration over key/value pairs.
foreach (pair; aa.byPair)
{
pairs ~= pair;
}
// Iteration order is implementation-dependent, so we should sort it to get
// a fixed order.
sort(pairs);
assert(pairs == [
tuple("a", 1),
tuple("b", 2),
tuple("c", 3)
]);
}
我不好,我确实输入了它。仍然有问题。 – StillLearningToCode