Last active
January 9, 2019 22:18
-
-
Save yayaa/8a181b4923d708ac06a520d5b81f64a7 to your computer and use it in GitHub Desktop.
Improving the code - 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Fruit( | |
val name: String?, | |
val isRotten: Boolean, | |
val color: Color | |
) | |
fun getFruits(): List<Fruit> { TODO() } | |
fun main() { | |
val fruits = getFruits() | |
for(index in 0 until fruits.size) { | |
val fruit = fruits[index] | |
if (fruit.name != null && !fruit.isRotten && fruit.color == Color.ORANGE) { | |
println("Yay! It's an orange ${fruit.name}") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment