我想知道Map的执行情况
void main(){
var info = userInfo(); /* what can I pass here as args? */
print(info);
}
userInfo(Map user){
/* what do I write here? */
}
你好,你可以传递一个地图,并使用地图如下
void main(){
Map user_map=
{
"first_name" : "fname",
"last_name" : "lname",
"gender" : "male",
"location" :
{ "state" : "state",
"country" : "country",
"place" : "place"
}
}
var info = userInfo(user_map); /* what can I pass here as args? */
print(info);
}
userInfo(Map user){
/* here you can use the map values like if you want to print the value of key
first_name */
print(user["first_name"]);
}