반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- gas
- Redshift
- PostgreSQL
- 파이썬
- math
- Java
- django
- Python
- Google Spreadsheet
- PANDAS
- array
- dataframe
- numpy
- Kotlin
- Tkinter
- PySpark
- Mac
- c#
- Github
- Apache
- list
- hive
- Google Excel
- GIT
- Excel
- matplotlib
- string
- google apps script
- SQL
Archives
- Today
- Total
달나라 노트
Kotlin - repeat (특정 문자열 n번 반복하기) 본문
728x90
반응형
repeat 함수는 어떤 문자열을 주어진 횟수만큼 반복합니다.
또는 어떤 함수를 주어진 횟수만큼 반복하게 되죠.
fun main() {
println("A".repeat(5)) // 1
repeat(5) { // 2
print("B")
}
}
-- Result
AAAAA
BBBBB
1. A라는 문자열을 5번 반복하여 이어붙입니다. 따라서 AAAAA가 출력됩니다.
2. B라는 문자열을 출력하는 print("B") 함수를 5번 실행합니다.
728x90
반응형
'Kotlin' 카테고리의 다른 글
Kotlin - Abstract class (0) | 2021.03.18 |
---|---|
Kotlin - random() (범위 자료형과 랜덤 숫자뽑기) (0) | 2021.03.16 |
Kotlin - apply (객체의 attribute 변경하기) (0) | 2021.03.16 |
Kotlin - lambda function (한줄로 함수쓰고 initialize 하기) (0) | 2021.03.16 |
Kotlin - data class (data 저장에 유용한 class) (0) | 2021.03.16 |
Comments