Aggiunta di un elemento a un valore di elenco all'interno di un array associativoCIAO,
Sto cercando di aggiungere un elemento in un array associativo in cui il valore è un elenco e l'elemento deve essere aggiunto all'elenco all'interno dell'array associativo.
Per esempio:
cary = ["high schools" => {"Cary", "Green Hope", "Panther Creek"}, "population" => 116244, "state" => "NC", "weather" => "sunny"] ;
In questo,
1. Come posso aggiungere una nuova voce all'elenco delle "scuole superiori"?
2. Come posso convertire il valore "meteo" in elenco? ad esempio "meteo" => {"soleggiato", "umido"}
Qualsiasi aiuto riguardo a questo è molto apprezzato.
Grazie,
Dileep
Oggetto: Aggiunta di un elemento a un valore di elenco all'interno di un array associativoDi solito c'è più di un modo con JSL. Ecco il mio modo:
cary = ["high schools" => {"Cary", "Green Hope", "Panther Creek"}, "population" => 116244, "state" => "NC", "weather" => "sunny"];
Insert Into( cary["high schools"], "Black Bear" );
cary["weather"] = { "sunny", "humid" };
Sono sicuro che i dettagli specifici determineranno quale sia il modo migliore per te in questo caso.
Oggetto: Aggiunta di un elemento a un valore di elenco all'interno di un array associativoProbabilmente c'è un modo più semplice, ma il seguente sembra funzionare.
cary = ["high schools" => {"Cary", "Green Hope", "Panther Creek"}, "population" => 116244,
"state" => "NC",
"weather" => "sunny"];
// 1.
cary << Insert("high schools", Insert(cary["high schools"], "another school"));
// 2.
cary << Insert("weather", Eval List(Insert(List(cary["weather"]), "humid")));
Show(cary);
/*:
cary = ["high schools" => {"Cary", "Green Hope", "Panther Creek", "another school"}, "population" => 116244, "state" => "NC", "weather" => {"sunny", "humid"}];