package com.casic.detector.extensions

/**
 * ArrayList扩展方法
 */

//将集合格式化成满足上传格式的数据
fun ArrayList<String>.reformat(): String {
    if (this.isEmpty()) return ""
    val builder = StringBuilder()
    //循环遍历元素，同时得到元素index(下标)
    this.forEachIndexed { index, s ->
        if (index == this.size - 1) {
            builder.append(s)
        } else {
            builder.append(s).append(",")
        }
    }
    return builder.toString()
}