kotlin - for, while
for 문 package com.example.myapplication.kotiln fun main(array: Array) { // list 선언 val a = mutableListOf(1, 2, 3, 4, 5, 5, 6, 7, 8, 9) // for 문 for (item in a) { println(item) } // 인덱스 포함 출력 for ((index, item) in a.withIndex()) { println("index : " + index) println("item : " + item) } // 람다 a.forEach { println(it) } a.forEach { item -> println(item) } // 람다 ( 인덱스 포함 ) a.forEachIndexed { index, i..
2020. 6. 11.
kotlin - 함수 응용, 앨비스 연산자, when, if, else-if, Array, list, set, map
함수응용 fun plusTree(first: Int, second: Int, third: Int): Int{ return first + second + third } fun minusTree(first: Int, second: Int, third: Int) = first - second - third // 디폴트 파라미터 설정 fun multipleTree(first: Int = 1, second: Int = 1, third : Int =1) : Int{ return first*second*third } fun showMyPlus(first:Int, second: Int): Int{ println("ShowMyPlus First : " + first) println("ShowMyPlus Second : ..
2020. 6. 11.