코틀린53 [Kotlin in Action] 1.1 코틀린 맛보기 코틀린의 특징을 보여줄 수 있는 작은 예제data class Person(val name: String, ) { // 최상위 함수 val persons = listOf(Person("영희"), Person("철수", age = 29)) // 이름이 붙은 파라미터 val oldest = persons.maxBy { it.age ?: 0 } // 람다 식과 엘비스 연산자 println("나이가 가장 많은 사람: $oldest") // 문자열 템플릿}// 결과 나이가 가장 많은 사람: Person(name=철수, age=29) // toString 자동 생성 예제에서 알 수 있는 코틀린 특징1. age 프로퍼티의 디폴트 값은 null2. 영희의 나이를.. 2025. 3. 13. [Spring] Mockito Inline Mock 경고 (경고 메시지)더보기Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK. Please add Mockito as an agent to your build what is described in Mockito's documentation: https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#0.3WARNING: A Java agent has been loaded dynamically (/path/to/byte-buddy-agent.jar)WARNING.. 2025. 2. 22. [Kotlin] 정적 팩토리 메소드 enum class IssueType { BUG, TASK; companion object { fun of (type: String) = valueOf(type.uppercase()) }}자바 느낌의 정적 팩토리 메소드 enum class IssueType { BUG, TASK; companion object { operator fun invoke(type: String) = valueOf(type.uppercase()) }}fun test() { IssueType("BUG")}코틀린에서 자체 지원하는 정적 팩토리 메소드 `.invoke`를 생략해도 위처럼 enum을 사용할 수 있다.// invoke 생략 가능IssueType.invoke.. 2023. 12. 26. 이전 1 ··· 8 9 10 11 다음