REKLAM ALANI

Swift Programlama - Tuple Değerlerine Erişme ve Ekrana Yazdırma

Swift Programlama - Tuple Değerlerine Erişme ve Ekrana Yazdırma

avatar UçanKelebek
Aktif Üye
4972
#1
Yorumu Paylaş

Koddaki açıklama satırlarında açıklamaları görebilirsiniz.
 
Kod:
let statusCode = 404
let statusMessage = "Not Found"
/* statusCode adında bir int değişken ve statusMessage 
adında bir string değişken oluşturup değerlerini atadık.*/

let (statusCode, statusMessage) = http404Error
/* bu iki değişkeni bir araya getirerek http404Error adında 
bir tuple oluşturduk */

println("The status code is (statusCode)")
// ekrana "The status code is 404" yazdırır
println("The status message is (statusMessage)")
// ekrana "The status message is Not Found" yazdırır

println("The status code is (http404Error.0)")
/* burada tuple'ın ilk elemanına ulaşılıyor
ekrana "The status code is 404" yazdırır */

println("The status message is (http404Error.1)")
/* burada tuple'ın 2. elemanına ulaşılır
ekrana "The status message is Not Found"yazdırır. */

println("The status code is (http404Error.statusCode)")
/* yada direkt olarak tuple'ın bileşenlerine de ulaşabiliriz.
ekrana "The status code is 404" yazdırır */

println("The status message is (http404Error.statusMessage)")
// ekrana "The status message is Not Found" yazdırır 
deneme
Aktif Üye

Konuda Ara

1 Yorum

^Phoenix^

քɦօɛռɨӼ ɖɨʐǟʏռ

Aktif Üye
avatar
^Phoenix^
20-07-2020, Saat: 00:31
20-07-2020, Saat: 00:31
#2
Yorumu Paylaş
Konu için teşekkür ederim.
Yararlı Olmuş  Parmak At


Konuyu Okuyanlar: