swiftでappendを使い配列にstringをfor文で加えようとしているのですが、なぜか複数回おなじStringが配列に加えられ複数の配列ができてしまいます
使っているfor文はいぜん使ったもので、そのときは異常がなかったのですが、なぜか今回は異常が出ます
間違えている点がわかるかたがいれば教えて下さい
swift
1let ListA = ["ACST", "ACTTU", "ADUS", "ACGLO", "ARRY", "AUDC", "BHFAL", "COWNZ", "CSGS", "DEACW", "ESLT", "ENTG", "FUNC", "FISV", "GMAB", "GECCN", "GRFS", "HAS", "HCAT", "HELE", "HOLX", "PFM", "BGRN", "LK", "NYMTN", "NVCR", "ODT", "OPINI", "VETS", "PEGI"] 2 3 for str in oo[0...29] { 4 let aa:String = "https://www.marketwatch.com/investing/stock/(str)/charts" 5 todayStocks.append(aa) 6 7 print(todayStocks) 8 9 10
swift
1//結果 2//理想 3["https://www.marketwatch.com/investing/stock/ACST/charts", "https://www.marketwatch.com/investing/stock/ACTTU/charts", "https://www.marketwatch.com/investing/stock/ADUS/charts", "https://www.marketwatch.com/investing/stock/ACGLO/charts", "https://www.marketwatch.com/investing/stock/ARRY/charts", "https://www.marketwatch.com/investing/stock/AUDC/charts", "https://www.marketwatch.com/investing/stock/BHFAL/charts", "https://www.marketwatch.com/investing/stock/COWNZ/charts", "https://www.marketwatch.com/investing/stock/CSGS/charts", "https://www.marketwatch.com/investing/stock/DEACW/charts", "https://www.marketwatch.com/investing/stock/ESLT/charts", "https://www.marketwatch.com/investing/stock/ENTG/charts", "https://www.marketwatch.com/investing/stock/FUNC/charts", "https://www.marketwatch.com/investing/stock/FISV/charts", "https://www.marketwatch.com/investing/stock/GMAB/charts", "https://www.marketwatch.com/investing/stock/GECCN/charts", "https://www.marketwatch.com/investing/stock/GRFS/charts", "https://www.marketwatch.com/investing/stock/HAS/charts", "https://www.marketwatch.com/investing/stock/HCAT/charts", "https://www.marketwatch.com/investing/stock/HELE/charts", "https://www.marketwatch.com/investing/stock/HOLX/charts", "https://www.marketwatch.com/investing/stock/PFM/charts", "https://www.marketwatch.com/investing/stock/BGRN/charts", "https://www.marketwatch.com/investing/stock/LK/charts", "https://www.marketwatch.com/investing/stock/NYMTN/charts", "https://www.marketwatch.com/investing/stock/NVCR/charts", "https://www.marketwatch.com/investing/stock/ODT/charts", "https://www.marketwatch.com/investing/stock/OPINI/charts", "https://www.marketwatch.com/investing/stock/VETS/charts", "https://www.marketwatch.com/investing/stock/PEGI/charts"] 4 5 6//現実 7["https://www.marketwatch.com/investing/stock/ACST/charts"] 8["https://www.marketwatch.com/investing/stock/ACST/charts", "https://www.marketwatch.com/investing/stock/ACTTU/charts"] 9["https://www.marketwatch.com/investing/stock/ACST/charts", "https://www.marketwatch.com/investing/stock/ACTTU/charts", "https://www.marketwatch.com/investing/stock/ADUS/charts"] 10["https://www.marketwatch.com/investing/stock/ACST/charts", "https://www.marketwatch.com/investing/stock/ACTTU/charts", "https://www.marketwatch.com/investing/stock/ADUS/charts", "https://www.marketwatch.com/investing/stock/ACGLO/charts"] 11["https://www.marketwatch.com/investing/stock/ACST/charts", "https://www.marketwatch.com/investing/stock/ACTTU/charts", "https://www.marketwatch.com/investing/stock/ADUS/charts", "https://www.marketwatch.com/investing/stock/ACGLO/charts", "https://www.marketwatch.com/investing/stock/ARRY/charts"] 12コード
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/01 14:19