Skip to content

Commit 94b4650

Browse files
author
alfredo-toledano
committed
doc(docs.topics.arrays): add notes
1 parent 50dd122 commit 94b4650

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

docs/topics/arrays.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
[//]: # (title: Arrays)
22

3-
An array is a data structure that holds a fixed number of values of the same type or its subtypes.
4-
The most common type of array in Kotlin is the object-type array, represented by the [`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/) class.
3+
* := data structure / holds a fixed number of values / SAME type or its subtypes
4+
* 👁️object-type array 👁️
5+
* most common type of array | Kotlin
6+
* -- represented by the -- [`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/) class
7+
* if primitives | object-type array -> bad performance impact
8+
* Reason: 🧠 because your primitives are [boxed | objects](https://docs.oracle.com/javase/specs/jls/se22/html/jls-5.html#jls-5.1.7) 🧠
9+
* alternative : [primitive-type arrays](#primitive-type-arrays)
10+
* Reason: 🧠 avoid boxing overhead 🧠
511

6-
> If you use primitives in an object-type array, this has a performance impact because your primitives are [boxed](https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html)
7-
> into objects. To avoid boxing overhead, use [primitive-type arrays](#primitive-type-arrays) instead.
8-
>
9-
{type="note"}
1012

1113
## When to use arrays
1214

15+
* TODO:
1316
Use arrays in Kotlin when you have specialized low-level requirements that you need to meet. For example, if you have
1417
performance requirements beyond what is needed for regular applications, or you need to build custom data structures. If
1518
you don't have these sorts of restrictions, use [collections](collections-overview.md) instead.
@@ -379,6 +382,7 @@ fun main() {
379382

380383
## What's next?
381384

382-
* To learn more about why we recommend using collections for most use cases, read our [Collections overview](collections-overview.md).
383-
* Learn about other [basic types](basic-types.md).
384-
* If you are a Java developer, read our Java to Kotlin migration guide for [Collections](java-to-kotlin-collections-guide.md).
385+
* Check
386+
* [Collections overview](collections-overview.md)
387+
* other [basic types](basic-types.md)
388+
* If you are a Java developer -> read our Java -- to -- Kotlin migration guide for [Collections](java-to-kotlin-collections-guide.md)

0 commit comments

Comments
 (0)