Data & Safety

Hüma offers advanced tools for managing your application's data flow and handling unexpected situations. Handle data sets with Lists and Dictionaries, and prevent crashes with the 'dene...yakala' structure.

01Lists & Dictionaries

Hüma lists are dynamic. Dictionaries (Maps) are optimized for storing key-value pairs.

listeler.hb
1
2
3
4
5
6
7
8
9
10
11
12
// Liste Oluşturma
sayılar = [1, 2, 3] olsun
// Eleman ekleme
sayılar'a [5]'i ekle;
// Elemana erişim (indeks ile)
// Removing element at index 0
sayılar'dan [0]'ı çıkar;
// Listeyi yazdır
sayılar'ı yazdır;

Sözlükler (Dictionaries)

Dictionaries are used to store key-value pairs. They are written in 'key': value format inside curly braces.

sozlukler.hb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Sözlük (Dictionary) Oluşturma
ayarlar = {
"tema": "koyu",
"dil": "tr",
"sürüm": 1.0
} olsun
// Değere erişim (Ek sistemi ile)
yazdır ayarlar'ın tema'sı;
// Değere erişim (Metot ile)
yazdır ayarlar.getir("dil");
// Değer güncelleme
ayarlar.ayarla("sürüm", 2.0);
Data StructureSyntaxDescription
ListeL = [1, 2] olsunIndex-based ordered array
SözlükS = { 'a': 1 } olsunKey-value based map
Erişim (Sözlük)S'nin anahtar'ıRead value via suffix
Metot (Sözlük)S.getir('a')Read value via method

02Structural Error Handling

Provides a safe exit strategy for bottlenecks in your programs. Use'dene...yakala' (try...catch) to catch errors and assign the message to a variable.

hata_yonetimi.hb
1
2
3
4
5
6
// Hata Yönetimi (dene / yakala)
dene {
sonuç = 10 / 0 olsun
} yakala hata_mesajı {
"Hata yakalandı: " + hata_mesajı'nı yazdır;
}
infoSafe Execution

Critical errors like division by zero or index out of bounds are caught within the 'dene' block, preventing program crashes.