展示了如何操作关联数组(Object
类型),包括遍历数组和合并两个关联数组。
; Create an associative array【关联数组/迭代】 obj := Object("red", 0xFF0000, "blue", 0x0000FF, "green", 0x00FF00) enum := obj._NewEnum() While enum[key, value] t .= key "=" value "`n" MsgBox % t ; 关联数组/合并 base := {"name":"火箭溜冰鞋", "price":12.75, "color":"yellow"} update := {"price":15.25, "color":"red", "year":1974} Merged := merge(base, update) for k, v in Merged result .= k " : " v "`n" MsgBox % result merge(base, update){ Merged := {} for k, v in base Merged[k] := v for k, v in update Merged[k] := v return Merged }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)