Skip to content

Commit bb0f28a

Browse files
committed
docs: revised 03_Smart Casts.md
1 parent 1023ac0 commit bb0f28a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

examples/06_productivity_boosters/04_Smart Casts.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Smart Casts
22

33

4-
The Kotlin compiler is smart enough to perform type casts automatically in most cases, including
5-
1. Casts from nullable types to their non-nullable counterparts
6-
2. Casts from a supertype to a subtype
4+
The Kotlin compiler is smart enough to perform type casts automatically in most cases, including:
5+
1. Casts from nullable types to their non-nullable counterparts.
6+
2. Casts from a supertype to a subtype.
77

88
<div class="language-kotlin" theme="idea" data-min-compiler-version="1.3">
99

@@ -38,11 +38,10 @@ fun main() {
3838

3939
</div>
4040

41+
1. Declaring a nullable variable.
42+
2. Smart-cast to non-nullable (thus allowing direct access to `isLeapYear`).
43+
3. Smart-cast inside a condition (this is possible because, like Java, Kotlin uses [short-circuiting](https://en.wikipedia.org/wiki/Short-circuit_evaluation)).
44+
4. Smart-cast inside acondition (also enabled by short-circuiting).
45+
5. Smart-cast to the subtype `LocalDate`.
4146

42-
1. Declares a nullable variable
43-
2. Smart-cast to non-nullable (thus allowing direct access to `isLeapYear`)
44-
3. Smart-cast inside condition (this is possible because, like Java, Kotlin uses [short-circuiting](https://en.wikipedia.org/wiki/Short-circuit_evaluation))
45-
4. Smart-cast inside condition (also enabled by short-circuiting)
46-
5. Smart-cast to subtype LocalDate
47-
48-
This way, you can automatically use variables as desired most of the time without doing obvious casts manually.
47+
This way, you can automatically use variables as desired in most cases without doing obvious casts manually.

0 commit comments

Comments
 (0)