[TypeScript] Dictionary範例

摘要:[TypeScript] Dictionary範例

[TypeScript] Dictionary範例

Playground

Samples

class Dictionary {
    [index: string]: string;
}

class Test {

    public run() {
        var parameters = new Dictionary();
        parameters["A"] = "A01";
        parameters["B"] = "B01";
        parameters["C"] = "C01";

        for (var key in parameters) {
            alert(
                "key=" + key + "\n" +
                "value=" + parameters[key] + "\n"
                );
        }
    }
}

var test = new Test();
test.run();
期許自己
能以更簡潔的文字與程式碼,傳達出程式設計背後的精神。
真正做到「以形寫神」的境界。