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
12345678// Fonksiyon Tanımlamatopla fonksiyon olsun a, b alsın { a + b'yi döndür}// Fonksiyon çağırmasonuç = topla(5, 10) olsun"Sonuç: " + sonuç'u yazdır;| Token | Meaning | Role |
|---|---|---|
| fonksiyon olsun | function | Declares a function |
| alsın | takes / params | Introduces parameter list |
| döndür | return | Returns 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
1234567891011121314151617// Sınıf Tanımlamaaraç 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şturmaaraba = araç() olsunaraba.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.