function

컬렉션의 원소를 element; element; element .. 로 출력하는 함수를 만들어보자. fun joinToString( collection: Collection, // 제네릭 separator: String, prefix: String, postfix: String ): String { val result = StringBuilder(prefix); for((index, element) in collection.withIndex()){ if(index > 0) result.append(separator) result.append(element) } result.append(postfix) return result.toString() } fun main() { var list = listOf(..
Function 함수적 인터페이스는 매개값과 리턴값이 있는 applyXXX() 메소드를 가지고 있다. 이 메소드는 매개값을 리턴값으로 매핑(타입 변환)하는 역할을 한다. 인터페이스명 추상 메소드 설명 Function R apply(T t) 객체 T를 객체 R로 매핑 BiFunction R apply(T t, U u) 객체 T, U를 객체 R로 매핑 DoubleFunction R apply(double value) double를 객체 R로 매핑 IntFunction R apply(int value) int를 객체 R로 매핑 IntToDoubleFunction double applyAsDouble(int value) int를 double로 매핑 IntToLongFunction long applyAsLong(..
깡냉쓰
'function' 태그의 글 목록