diff --git a/README.md b/README.md index 6bae9df..67d0b56 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ [![alt text][InstagramIcon]][Instagram] [![alt text][TelegramIcon]][Telegram] +### #171 Kotlin Average Usage +![alt text](/screenshots/Average.png) + ### #170 View Visiblity Extensions ![alt text](/screenshots/ViewVisiblityExt.png) diff --git a/codes/Average.kt b/codes/Average.kt new file mode 100644 index 0000000..5c3cf9a --- /dev/null +++ b/codes/Average.kt @@ -0,0 +1,7 @@ +val list = arrayListOf(2.0, 3.0, 7.0) +var average = 0 +list.forEach{ + average += it.toInt() +} +println(average/list.size) // 4 +println(list.average().toInt()) // 4 \ No newline at end of file diff --git a/screenshots/Average.png b/screenshots/Average.png new file mode 100644 index 0000000..bc5c7c9 Binary files /dev/null and b/screenshots/Average.png differ