Xóa bài viết
Bạn có chắc chắn muốn xóa bài viết này không ?
Xóa bình luận
Bạn có chắc chắn muốn xóa bình luận này không ?
Kotlin Partition method – split List, Map of Objects example
Kotlin Partition method – split List, Map of Objects example
https://grokonez.com/kotlin/kotlin-partition-method-split-list-map-objects-example
This Kotlin tutorial shows you example that uses Partition
method to split List
, Map
of Objects.
I. Technology
- Java 1.8
- Kotlin 1.1.2
II. Overview
- We will split List/Map of
Product(name,quantity)
objects into 2 Lists usingpartition()
method:inline fun Iterable.partition( predicate: (T) -> Boolean ): Pair, List>
predicate
is the condition for the first List ofPair
, all remain items will be contained in the second List. - We also use Destructuring Declaration syntax to destructure the
Pair
into 2 Lists.val (positive, negative) = List.partition { predicate }
III. Practice
0. Product Class
https://grokonez.com/kotlin/kotlin-partition-method-split-list-map-objects-example
Bình luận

{{ comment.user.name }}
Bỏ hay
Hay

Cùng một tác giả

1
0
Tutorial Link: (Link) (Ảnh) Django is a Pythonbased free and opensource web framework that follows the modeltemplateview architectural pattern. A...

1
0
https://loizenai.com/angular11nodejspostgresqlcrudexample/ Angular 11 Node.js PostgreSQL Crud Example (Ảnh) Tutorial: “Angular 11 Node.js Postg...

1
0
Angular Spring Boot jwt Authentication Example Github https://loizenai.com/angularspringbootjwt/ (Ảnh) Tutorial: ” Angular Spring Boot jwt Authe...