miha-x64
09/06/2019, 4:56 PMmarstran
09/06/2019, 6:43 PMinline class NonEmptyList<T>(val list: List<T>) {
contract { list.isNotEmpty() implies list is NonEmptyList }
}
fun someFunction(list: List<T>) {
if (list.isNotEmpty()) {
// list is "smart cast" (or conforms) to NonEmptyList.
}
}
dr.dreigh
09/06/2019, 6:47 PMmarstran
09/06/2019, 6:51 PMdr.dreigh
09/06/2019, 6:59 PMmarstran
09/06/2019, 7:24 PMdr.dreigh
09/06/2019, 7:25 PM