Tag: 判别联合

Kotlin和歧视工会(总数类型)

Kotlin有什么像歧视工会(总和类型)? 什么是这个(F#)的惯用Kotlin翻译: type OrderMessage = | New of Id: int * Quantity: int | Cancel of Id: int let handleMessage msg = match msg with | New(id, qty) -> handleNew id qty | Cancel(id) -> handleCxl id