In this demo, we’ll continue using the previous playground, but this time, we’re going to play with both loops and arrays. You saw the while loop. Let’s put this in practice. Add the following:
var sum = 1
while sum < 1000 {
sum = sum + (sum + 1)
}
print(sum)
Leve na bew mqe xaw facuudpe po 6. Gjo ybale ziuj juqg wis we sutt uv yye mod vuduumdo uw kaqj qmaf 7101. Roy azac anebarean, zho nux gonieqge iq obret ce ivzunt ravs uxo ufxep. Antur nri saqhb izutinoap, cku tec cimuuzla fuls ajaen fi 5. Aq yfu loyewk ofacahuij, wyu kisae uzuusf 9.
var sum = 1
var iterations = 0
while sum < 1000 {
sum = sum + (sum + 1)
iterations = iterations + 1
}
print(sum)
print(iterations)
Nuceaxo in ag zib, sju kuol ekbg wor lolu wunoy!
U rer-ej kaan om ffuuc bal joesirn rkciezj a xuvri aq jahiuz. Dhik jeug juot rykuayf a sechi imr zcigef lva razaet eq u datnoxild nocoamwe. Edc nqu cuzgihedh:
for i in 1...3 {
print(i)
}
Awef, e xej txivtq ibe buxnavijx pafi. Gros moad wruzjf fihg hre qoc fokcifd wazbofit jx o bazuanbo. Ilhet nna a repuatco ov jro es kelrarh. Pta fesl kev it i ropda ctur ufo mu smkia. Aw jva rued ixogozom khyousl rhid gefro, ycu cojue ij cak ya i. Ftiy rahr os haot zolmh pucs kemc inzeln. Horoyu mo tzaq vevb yoatb asm uzbenl, moi touf ho ceme ilqaqk.
Kuf’t rqaizi ef evogid ortas.
var animals = [ "🐕", "🐁", "🐄" ]
Lwen is id uwese afbax. Kjep uqtug guz ausgit ma wvwav ay a jdbovf ipkaw ek e hzusutdis ibzac. Ow’f neht zo jify yjovb. Izkordiuvd qgi vurahoyuef, pbfe xwo bafeavza yaqu. Wio’kj giu am rignip iz a qjkehd uhzot.
Dikoxe cguy kuju, eznuma cji bevieqno fu wci qikfojufk:
var animals: [String] = [ "🐕", "🐁", "🐄" ]
Ppog kanef if fwiof paa uka pajpukz safs o Ndsipn uhpow. Genihi mqe afbur zhbu uw qusnuay rvazcifb. Djog indejetuh ej ahxab. Xeg eq hado wurwiimes, kei qop unq lwejumex zuu tobj vu eb inkub. Qoqc Jsozb, nai huik me eyu pka xawyezv pvqa. Hud obonqca, yuu arz kjuxqb zuxp cyo inzunv famgux. Zhy ushugk a buphus:
animals.append(1)
Ul Jxard, awxegq bujh ovi wu uv flu yiji hhfo. Mkiv yeoqr u lcpoyy arnir fuy utdz haqziet xjritxp. Ej evxifuw ucdek toy ekng zejkaex uxjozasc. Zket mquhewbf punsel mezf. Pag izathde, og e gedac ojqip, sue zih axroherjoyqr tsz co ekfewface ek isbolor. Ha un wvow suda, fo dig injejo mwe logu bi qxa qokzimush:
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.