Skip to content
Commitwise
Menu

Extension

Also called: Extension function, Extension method

A way to add methods or computed properties to an existing type, even one you didn't write, without changing or subclassing it.

Definition

Swift extensions and Kotlin extension functions let you call new helpers with normal dot syntax, such as name.initials. They can't store new data or override existing methods, and they are chosen by the variable's declared type at compile time. Java has no extensions and uses static helper methods instead; TypeScript uses plain functions.

In practice

extension Date { var isWeekend: Bool { … } } lets any Swift code write date.isWeekend.

Related terms

Esc

Type to search the whole site.