DEV Community

loading...

Kotlin – average() function with Kotlin Array & List examples

loizenai profile image loizenai ・1 min read

https://grokonez.com/kotlin/kotlin-average-function-kotlin-array-list-examples

Kotlin – average() function with Kotlin Array & List examples

In the tutorial, JavaSampleApproach will show you how to use Kotlin average() function with Kotlin Array & List collections by examples.

I. Kotlin List with average() function

With Kotlin List, We use following method signatures of average():


fun Iterable.average(): Double (source)
fun Iterable.average(): Double (source)
fun Iterable.average(): Double (source)
fun Iterable.average(): Double (source)
fun Iterable.average(): Double (source)
fun Iterable.average(): Double (source)

-> Returns an average value of elements in the collection.

Practice:

More at:

https://grokonez.com/kotlin/kotlin-average-function-kotlin-array-list-examples

Discussion (0)

pic
Editor guide