然而,一旦將這些檢測提取到單獨的函式中,所有智慧轉換都立即消失了:
為了改善在此類場景中的行為,Kotlin 1.3 引入了稱為 契約 的實驗性機制。
關鍵詞contract,視訊中說法如下:create contracts and say that your function matches your the argument to a function match certain conditions and that basically is guaranteeing you a certain level of code correctness in your actual code