我想通過在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