在Swift中迭代数组w /显式对象类型

前端之家收集整理的这篇文章主要介绍了在Swift中迭代数组w /显式对象类型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个数组:
  1. let individualscores = [75,43,103,87,12]

我这样迭代:

  1. for score in individualscores {
  2.  
  3. }

但是,有没有明确声明对象类型的方法?我认为它会派上用场后的自定义对象,或其他原因。就像是:

  1. for Integer score in individualscores {
  2.  
  3. }
当你键入一个变量,你做:
  1. var score: Int

你在循环中做同样的事情:

  1. for score: Int in individualscores {
  2.  
  3. }

在这方面似乎是相当一致的。

猜你在找的Swift相关文章