Logic & Structuring

Hüma supports both functional and object-oriented programming paradigms. In this section, you'll learn how to make your code modular and how to build complex data structures.

01Functions

Functions are the fundamental building blocks of Hüma. You can easily manage data flow with 'alsın' and 'döndür' structures.

fonksiyonlar.hb
1
2
3
4
5
6
7
8
// Fonksiyon Tanımlama
topla fonksiyon olsun a, b alsın {
a + b'yi döndür
}
// Fonksiyon çağırma
sonuç = topla(5, 10) olsun
"Sonuç: " + sonuç'u yazdır;
TokenMeaningRole
fonksiyon olsunfunctionDeclares a function
alsıntakes / paramsIntroduces parameter list
döndürreturnReturns a value

02Classes (Object-Oriented)

Classes in Hüma are powerful structures that hold data and behavior together. You can access object properties with the 'bu' (self) keyword.

siniflar.hb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Sınıf Tanımlama
araç sınıf olsun {
hız = 0 olsun
hızlan fonksiyon olsun miktar alsın {
kendisi'nin hız'ı = kendisi'nin hız'ı + miktar olsun
}
hız_göster fonksiyon olsun {
"Mevcut hız: " + kendisi'nin hız'ı yazdır;
}
}
// Nesne oluşturma
araba = araç() olsun
araba.hızlan(10)
araba.hız_göster()
infoMethods & Self

Functions inside a class are its methods. They can access instance properties using the 'kendisi' (self) keyword.