1. 程式人生 > >kotlin 通過 下標比對

kotlin 通過 下標比對

  //通過憑證日期排序
        recordList.sortBy({it.loanDate})

        var certificateNumber = 1
        recordList.forEachIndexed{index,item ->
            (index > 0).y {
                (item.loanDate == recordList.get(index - 1).loanDate).y {
                    item.certificateNumber = certificateNumber
                } other {
                    certificateNumber
++ item.certificateNumber = certificateNumber } } other { item.certificateNumber = certificateNumber } }