SHARE
TWEET

Untitled

a guest Jul 12th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package thiha
  2. import kotlin.text.StringBuilder
  3. fun main(args: Array<String>) {
  4.     val x = 45
  5.     if (x.isEven()) println("$x is even") else println("$x is odd")
  6.     val days = arrayOf("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
  7.     println(days.combineAll())
  8.     val y = 44
  9.     if (y.isEven()) println("$y is even") else println("$y is odd")
  10. }
  11. private fun <T> Array<T>.combineAll(): Any {
  12.     val sb = StringBuilder()
  13.     this.forEach {
  14.         sb.append(it)
  15.     }
  16.     return sb.toString()
  17. }
  18. private fun Int.isEven(): Boolean {
  19.     if(this % 2 == 0) return true
  20.     return false
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top