为什么雨燕2.0​​的阵列,而不是所有元素打印出最后一个元素? [英] Why does Swift 2.0 print out last element in array instead of all elements?

查看:164
本文介绍了为什么雨燕2.0​​的阵列,而不是所有元素打印出最后一个元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这个阵列中打印出所有的元素,当我展示它,它只能打印出皮卡洗衣。

I'm trying to print out all the elements in this array, and when I display it, it only prints out Pickup laundry.

var todo = ["Return Calls", "Write blog", "Cook Dinner", "Pickup laundry"]

for element in todo {
print(element)
}

我不知道为什么这是错的...

I'm not sure why this is wrong...

推荐答案

我复制你的code和它粘贴到一个应用程序。我跑的应用程序。我看到这在控制台:

I copied your code and pasted it into an app. I ran the app. I saw this in the console:

Return Calls
Write blog
Cook Dinner
Pickup laundry

所以,我得出这样的结论要么你在说谎 - 这是不是你的code,或者说是不是印 - 或者你不知道如何测试(例如,你不知道如何阅读控制台或者你在操场,你不明白的地方的控制台)。

So I conclude that either you are lying — that is not your code, or that is not what is printed — or you don't know how to test (e.g. you don't know how to read the console or you're in a playground and you don't understand where the console is).

这篇关于为什么雨燕2.0​​的阵列,而不是所有元素打印出最后一个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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