September 2019
Intermediate to advanced
462 pages
11h 3m
English
Let’s write a main() function to call the getAirportStatus() function with a few different airport codes and print the status of the airports with those codes to the console. Create a file named AirportApp.kt in the directory src/main/kotlin/com/agiledeveloper/ui and key in the following code:
| | package com.agiledeveloper.ui |
| | |
| | import kotlinx.coroutines.* |
| | import com.agiledeveloper.airportstatus.* |
| | |
| | fun main() = runBlocking { |
| | getAirportStatus(listOf("SFO", "IAD", "IAH", "ORD", "LAX")) |
| | .forEach { println(it) } |
| | } |
Since getAirportStatus() is a function that may be suspended, it can only be called within a coroutine. So ...
Read now
Unlock full access