implements
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Declares that a type implements one or more interface contracts.
Aliases: implements
Syntax: class <name> implements <interface-list> <block>
Category#
type
Related#
Examples#
radix/corpus/implet/implet.fab (canonical · keyword)#
Declares that a type implements one or more interface contracts.
# =============================================================================
# implements — Declares that a type implements one or more interface contracts
# =============================================================================
#
# What this teaches:
# • Declares that a type implements one or more interface contracts.
# • Related keywords: class, interface
#
# Common mistakes:
# • Declaring `class implements Implendum` without implementing all required methods — every method signature in the interface must have a body in the class.
#
# See also: class, interface
# =============================================================================
# implements — class implements a interface (interface contract)
#
# class Nomen implements Implendum { … }
#
# GRAMMAR:
# genusDecl :← 'class' ident 'implements' ident '{' methodDecl* '}'
#
# EXPECTED OUTPUT:
# implet.expected — Aurelia from interface plenum().
interface Nominatum {
fn plenum() → string
}
class Civis implements Nominatum {
var string name
fn plenum() → string {
# satisfies interface requirement
return "§"(self.nomen)
}
}
main {
const Civis civis ← Civis { name = "Aurelia" }
print civis.plenum()
}Expected output:
Aurelia