[Kotlin] 코틀린 참고하기

2024. 7. 2. 23:15·Language/Kotlin
728x90

 

 

  • max / min

: 최대값과 최소값을 구하는 함수

fun main() {
    var i = 10
    var j = 20
    
    println("max: " + kotlin.math.max(i, j))
    println("min: " + kotlin.math.min(i, j))
}

 

 

  • random

: 랜덤한 값을 호출하는 객체

import kotlin.random.Random

fun main() {
    println("randomInt: " + Random.nextInt())
    println("randomInt: " + Random.nextInt(0, 100))
    println("randomDouble: " + Random.nextDouble())
    println("randomDouble: " + Random.nextDouble(0.0, 0.9))
}

 

 

type Alias

 

: 긴 이름의 클래스 혹은 함수 타입이 있을때 축약하거나 더 좋은 이름을 쓰고 싶을 때 

fun filterFruits(fruits: List<Fruit>, filter: (Fruit) -> boolean) {

}

의 코드를 아래와 같이 타입 별칭을 지정하여 개선할 수 있다.

 

typealias FruitFilter = (Fruit) -> Boolean

fun filterFruits(fruits: List<Fruit>, filter: FruitFilter){
}

 

 

as import

 

: 어떤 클래스나 함수를 임포트 할 때 이름을 바꾸는 기능

// 중복된 printHelloWorld() 함수가 있다고 가정

import com.lannstark.lec19.a.printHelloWorld as printHelloWorldA
import com.lannstark.lec19.a.printHelloWorld as printHelloWorldB

// 으로 가능하다.

 

 

 

 

 

 

※ 본 게시글의 정보가 잘못 되었거나 부족한 부분에 대한 피드백을 환영합니다.

 

 

* CopyRight 2024. Jay Park All rights reserved.

 
728x90
저작자표시 비영리 변경금지 (새창열림)

'Language > Kotlin' 카테고리의 다른 글

[Kotlin] 코틀린 코루틴  (247) 2024.07.02
[Kotlin] 코틀린 클래스  (258) 2024.07.02
[Kotlin] 코틀린 함수  (2) 2024.07.02
[Kotlin] 코틀린 조건문 / 반복문  (2955) 2024.07.02
[Kotlin] 코틀린 리스트/배열  (0) 2024.07.02
'Language/Kotlin' 카테고리의 다른 글
  • [Kotlin] 코틀린 코루틴
  • [Kotlin] 코틀린 클래스
  • [Kotlin] 코틀린 함수
  • [Kotlin] 코틀린 조건문 / 반복문
dev.parkjh
dev.parkjh
Jay Blog. Github: https://github.com/GreatPark96
  • dev.parkjh
    0과 1을 공부하다.
    dev.parkjh
  • 전체
    오늘
    어제
    • 분류 전체보기 (114)
      • Profile (2)
      • Paper (6)
      • Column (3)
      • Project (8)
        • Smart Home (3)
        • 3D Printing (5)
      • Front-End (0)
        • Web (3)
      • Back-End (8)
        • API (1)
        • DB (1)
        • Laravel (4)
      • Language (16)
        • Kotlin (11)
        • C, C++ (3)
        • JAVA (0)
        • python (2)
      • System (28)
        • Server (15)
        • Security (1)
        • Network (1)
        • Linux (8)
        • Cloud (3)
      • ETC (34)
        • Book Recommend (Computer) (3)
        • IoT (7)
        • BlockChain (7)
        • ETC (17)
      • My YOLO (1)
      • Note (4)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    3d프린터 초보
    ci/cd
    docker private register
    docker
    ncp container registry
    리눅스 파일동기화
    gitlab
    네이버클라우드
    nas
    coderabbit
    Database
    데이터 직렬화 포맷
    코틀린개발환경
    C언어
    Kotlin
    3D프린터 입문
    ai code review
    3D
    NAS HDD교체
    git
    linux job
    docker container
    Jenkins
    Notification
    work hour
    github
    3D모델링
    kubernetes
    3D프린터
    data serialization formats
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dev.parkjh
[Kotlin] 코틀린 참고하기
상단으로

티스토리툴바