ego
Translation status: हिन्दी reader-locale proof. Code fences render through the hi pipeline; prose is canonical Latin.
Refers to the current instance inside a method.
Aliases: self, this
Syntax: ego.<member>
Category#
object
Related#
Examples#
radix/corpus/ego/ego.fab (canonical · keyword)#
Refers to the current instance inside a method.
# =============================================================================
# ego — Refers to the current instance inside a method.
# =============================================================================
#
# What this teaches:
# • Self-reference — `ego.<member>` accesses the current instance's fields and methods inside a genus method.
# • Method definition — functions defined inside a genus block receive the instance as `ego`.
#
# Common mistakes:
# • Using `ego` outside a genus method — `ego` is only valid inside methods defined on a genus (SEM008).
#
# See also: generis, nexum
# =============================================================================
# ego — current genus instance reference
#
# ego.<field>
#
# GRAMMAR:
# memberExpr inside genus method :← 'ego' '.' ident
#
# EXPECTED OUTPUT:
# capsa: prima
class Capsa {
string titulus
fn narra() → string {
# ego = the receiver instance
return "capsa: " + self.titulus
}
}
main {
const _ capsa ← Capsa { titulus = "prima" }
print capsa.narra()
}Expected output:
capsa: prima