์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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
- Firebase
- DART
- recyclerview
- Linux
- ํ์ด์ฌ
- Flutter
- ์ด๋ชจ์ง๋ฉ๋ชจ
- Coroutine
- ๊ณต๋ถ์ง์ค
- jetpack compose
- bash
- androidx
- FSM
- Android
- 1์ธ๊ฐ๋ฐ์
- ๋ช ์ฌ๋ณด๊ฐ
- kotlin
- ๋ช ์ธ๋ชจ์
- ๋ฒค์๋ฏผํ๋ญํด๋ฆฐ
- Freesound
- Streaming
- ์์ธ์นผ๋ฆฌ๋ฒ6
- ๋ทํ๋ฆญ์ค
- ์ฝํ๋ฆฐ
- ์ข์๊ธํ์ฌํ๊ธฐ
- ASMR
- ์ฅ์๋ช ์ธ
- ์ด๋ชจ์ง
- ์คํ์์ค
- ๊ณต์๋ช ์ธ
Archives
- Today
- Total
Vintage appMaker์ Tech Blog
[kotlin] associate๋ฅผ ์ด์ฉํ list → Map ๋ณธ๋ฌธ
Source code or Tip/Android(Java, Kotlin)
[kotlin] associate๋ฅผ ์ด์ฉํ list → Map
VintageappMaker 2020. 12. 29. 11:32๐ข ๋ฆฌ์คํธํํ์ ๋ฐ์ดํฐ๋ฅผ map ํํ๋ก ๋ณํํ ๋ ์ ์ฉํ๊ฒ ์ฌ์ฉํ ์ ์๋ ๋ฉ์๋์ด๋ค.
fun main(args: Array<String>) {
// ์์ฐจ์ ์ธ ๊ฐ์ ๊ธฐ์ค์ผ๋ก map ์์ฑ
val player_reward = (1..100).associate{
it to reward(it)
}
(1..50).forEach { println ("${it}๋ฑ -> ${player_reward[it]}") }
}
fun reward(n: Int, baseMoney : Int = 1000): Int =
// if else์ ๊ฐ์ํ ๋ชฉ์
when {
n == 1 -> baseMoney * 10
n in 2..3 -> baseMoney * 5
n in 4..10 -> baseMoney * 2
else -> baseMoney
}
'Source code or Tip > Android(Java, Kotlin)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[kotlin] sealed class์ ๋์ฒดํฌ๋ฅผ ์ํ Elvis ์ฐ์ฐ์ (0) | 2021.01.06 |
---|---|
Newsletter - kotlin, Android (0) | 2021.01.01 |
Android ์ฑ์ ์ฟ ํกํํธ๋ ๋ฐฐ๋๋ฌ๊ธฐ (0) | 2020.12.25 |
Android App shortcut ๋ง๋ค๊ธฐ (0) | 2020.12.24 |
kotlin์์ xml์ ID๋ก ๋ณ์๋ฅผ ์๋์ผ๋ก ์ฝ์ด์ค์ง ๋ชปํ ๋ (0) | 2020.12.22 |
Comments