Skip to content

Commit 287708e

Browse files
committed
Alejandro review
1 parent 173fea1 commit 287708e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

docs/topics/extensions.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ Kotlin _extensions_ let you extend a class or an interface with new functionalit
44
design patterns like _Decorator_. They are useful when working with third-party libraries you can't modify
55
directly. Once created, you call these extensions as if they were members of the original class or interface.
66

7-
The most common forms of extensions are _extension functions_ and [_extension properties_](#extension-properties), which
8-
are available in [companion objects](#companion-object-extensions) as well as classes and interfaces.
7+
The most common forms of extensions are [_extension functions_](#extension-functions) and [_extension properties_](#extension-properties).
98

10-
Extensions don't modify the classes or interfaces they extend. By defining an extension, you aren't inserting new members,
9+
Importantly, extensions don't modify the classes or interfaces they extend. By defining an extension, you aren't inserting new members,
1110
only making new functions callable or new properties accessible via special syntax.
1211

1312
## Receivers
@@ -156,8 +155,8 @@ For more information about generics, see [generic functions](generics.md).
156155
### Nullable receivers
157156

158157
You can define extension functions with a nullable receiver type, which allows you to call them on a variable
159-
even if its value is null. When the receiver is `null`, `this` is also `null`. To avoid compiler errors, we recommend checking
160-
`this == null` check inside the function body when defining an extension with a nullable receiver.
158+
even if its value is null. When the receiver is `null`, `this` is also `null`. Make sure to handle nullability correctly
159+
within your functions. For example, use `this == null` checks inside function bodies, [safe calls `?.`](null-safety.md#safe-call-operator), or the [Elvis operator `?:`](null-safety.md#elvis-operator).
161160

162161
In this example, you can call the `.toString()` function without checking for `null` because the check already happens inside
163162
the extension function:

0 commit comments

Comments
 (0)