Objects in Soplang
Learn how to declare, modify, and manage walax (objects) in Soplang with Somali-first methods.
Objects in Soplang
Objects in Soplang are defined using the walax type. They store key–value pairs and provide Somali-first methods to inspect, modify, and copy structured data.
Declaring an Object – walax
declare_object.sop
walax qof = { magac: "Ayaan", da: 25, shaqo: "barayaal" }
Keys can be written as plain names (magac:) or as strings ("magac":).
Reading and Updating Properties
Use dot-notation to read a property, change it, or add a new one. Bracket-notation with a string key works too, which is useful when the key is stored in a variable. Use dherer() to count the properties.
properties.sop
qor(qof.magac) // Ayaan qor(qof["da"]) // 25 qof.da = 26 // update qof.magaalo = "Hargeysa" // add a new property door fure = "shaqo" qor(qof[fure]) // barayaal qor(dherer(qof)) // 4
Reading a property that does not exist returns null (printed as maran).
Core Object Methods
fure(), qiime(), and lamaane() return their results sorted alphabetically by key.
fure() – Get Keys
keys.sop
door keys = qof.fure() qor(keys) // [da, magaalo, magac, shaqo]
qiime() – Get Values
values.sop
door values = qof.qiime() qor(values)
lamaane() – Get Key-Value Pairs
pairs.sop
door pairs = qof.lamaane() qor(pairs)
leeyahay(x) – Has Key
has_key.sop
haddii (qof.leeyahay("magac")) { qor("Magaca wuu jiraa") }
tir(x) – Delete Key
delete.sop
qof.tir("shaqo") qor(qof)
kudar(obj) – Merge
kudar() returns a new object; the original objects are not changed.
merge.sop
walax A = {x: 1} walax B = {y: 2} walax C = A.kudar(B) qor(C) // {x: 1, y: 2}
nuqul() – Copy
copy.sop
walax asal = {a: 10, b: 20} walax copy = asal.nuqul() qor(copy)
nadiifi() – Clear All Properties
clear.sop
asal.nadiifi() qor("Cleared object: " + asal)
Gunaanad: walax waxay siisaa qaab awood badan oo lagu kaydiyo xog magacyo leh, iyadoo leh habab si buuxda ugu qoran Af-Soomaali.