Add ConstIterator to Dictionary.

This commit is contained in:
Yufeng Ying
2025-03-12 06:43:48 +08:00
parent 74907876d3
commit bebe037abf
34 changed files with 131 additions and 179 deletions

View File

@ -4029,11 +4029,9 @@ String String::format(const Variant &values, const String &placeholder) const {
}
} else if (values.get_type() == Variant::DICTIONARY) {
Dictionary d = values;
List<Variant> keys;
d.get_key_list(&keys);
for (const Variant &key : keys) {
new_string = new_string.replace(placeholder.replace("_", key), d[key]);
for (const KeyValue<Variant, Variant> &kv : d) {
new_string = new_string.replace(placeholder.replace("_", kv.key), kv.value);
}
} else if (values.get_type() == Variant::OBJECT) {
Object *obj = values.get_validated_object();