Open Avatarchik opened 2 months ago
Hi! Can someone help me? I tried different options but it didn’t work, sorting through the dictionary...
https://github.com/Tencent/puerts/blob/master/unity/Assets/core/upm/Editor/Resources/puerts/templates/dts.tpl.mjs#L241 here is an example.
and I remember that some has submitted a PR to support for (var item of CSDic)
#1555 . You can try
Hi! thanks, but I don't quite understand how to use it... var dic= Engine.DatValue("dat") as CS.System.Collections.Generic.Dictionary$2<string, object>;
for (var item of dic){ console.log(item) }
Error: TypeError: dicis not iterable
Try:
for (const [key,value] of dic) {
console.log(`map: ${key}: ${value}`)
}
Error: Type 'KeyValuePair$2<string, object>' must have a '[Symbol.iterator]()' method that returns an iterator.
Well you can try the first example
I don't quite understand how I should use this, can you help me? https://github.com/Tencent/puerts/blob/master/unity/Assets/core/upm/Editor/Resources/puerts/templates/dts.tpl.mjs#L241
Hi! can someone give an example of how I can read the Dictionary in JavaScript?
How can I iterate through a Dictionary in JavaScript? Analogue C# foreach (KeyValuePair<string, object> n in dic)