该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


To create an empty associative array, use the Associative Array() function or [=>].
cary = Associative Array();
cary = Associative Array();
cary["state"] = "NC";
cary["population"] = 116234;
cary["weather"] = "cloudy";
cary["population"] += 10;
cary["weather"] = "sunny";
cary["high schools"] = {"Cary", "Green Hope", "Panther Creek"};
cary = Associative Array();
cary << Set Default Value( "Cary, NC" );
cary << Get Default Value;
If there is no default value, Empty() is returned.
Besides the Set Default Value message, a default value can be set in the literal constructor using =>value without a key.
counts = ["a" => 10,
"b" => 3,
=> 0]; // default value of 0
counts["c"] += 1;
Show( counts );
In the first line, the default value is set to 0. In the second line, the key "c" does not exist in counts. In the output, the key "c" is created with the default value of 0 and then incremented by 1.
map = Associative Array();
map = Associative Array( 0 );
map = ["yes" => 0, "no" => 1];
map = ["yes" => 0, "no" => 1, => 2];
map = ["yes" => 0, "no" => 1, "alt" => ["a" => "1", "b" => "2"]];
map = Associative Array( {{"yes", 0}, {"no", 1}} );
map = Associative Array( {{"yes", 0}, {"no", 1}}, 2 );
map = Associative Array( {"yes", "no"}, {0, 1} );
map = Associative Array( {"yes", "no"}, {0, 1}, 2 );
map = Associative Array( :name, :height );
map = Associative Array(:name, :height, .);
set = Associative Array( {"yes", "no"} );
set = Associative Array( :name );