字典打印结果向后 [英] Dictionary printing results backwards

查看:90
本文介绍了字典打印结果向后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在视频教程中:

在16分钟内,快速无脚本教程介绍苹果Swift progrqmming语言
http://youtu.be/3tZig9AWMdc?t=9m10s

Quick unscripted tutorial introduction to apple Swift progrqmming language in 16 minutes http://youtu.be/3tZig9AWMdc?t=9m10s

我做了相同的作为他的事情,但是得到了结果。

I did the same thing as him, but got the results backwards

var names = [
    "1" : "...",
    "2" : "...2"
]

for (k,v) in names {
    println("key is \(k) : value is: \(v)")
}

输出: p>

Output:

Hello, World!
key is 2 : value is: ...2
key is 1 : value is: ...

我在这里缺少什么?

推荐答案

你什么都没有。

字典是无序集合。

文档


Swift's Dictionary类型是一个无序的集合。没有指定在迭代字典时检索键,值和键值对的顺序。

Swift’s Dictionary type is an unordered collection. The order in which keys, values, and key-value pairs are retrieved when iterating over a dictionary is not specified.

这篇关于字典打印结果向后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆