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
123456789101112// Liste Oluşturmasayılar = [1, 2, 3] olsun// Eleman eklemesayılar'a [5]'i ekle;// Elemana erişim (indeks ile)// Removing element at index 0sayılar'dan [0]'ı çıkar;// Listeyi yazdırsayı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
123456789101112131415// Sözlük (Dictionary) Oluşturmaayarlar = { "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üncellemeayarlar.ayarla("sürüm", 2.0);| Data Structure | Syntax | Description |
|---|---|---|
| Liste | L = [1, 2] olsun | Index-based ordered array |
| Sözlük | S = { 'a': 1 } olsun | Key-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
123456// 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.