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 Distinct() methods of List collection example
https://grokonez.com/kotlin/kotlin-distinct-methods-list-collection
Kotlin Distinct() methods of List collection example
In the tutorial, Grokonez will show you how to work with Kotlin distinct()
method of List collection.
I. Practice
1. distinct() method
distinct()
method is used to return a list that contains only distinct elements.
Method signature:
public fun <T> Iterable<T>.distinct(): List<T>
- Work with simple list:
val simpleList = listOf(1, 2, 3, 5, 3, 4, 1, 10, 13, 7, 10, 8)
println(simpleList)
// print on console
//->
/*
[1, 2, 3, 5, 3, 4, 1, 10, 13, 7, 10, 8]
*/
println(simpleList.distinct())
// print on console
// ->
/*
[1, 2, 3, 5, 4, 10, 13, 7, 8]
*/
- Work with Kotlin objects list:
More at:
https://grokonez.com/kotlin/kotlin-distinct-methods-list-collection
Kotlin Distinct() methods of List collection 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...
Bài viết liên quan

0
0
https://grokonez.com/kotlin/kotlinreadwritecsvfileexample How to read/write CSV file in Kotlin In this tutorial, we're gonna look at examples tha...