scala常用操作-去除字串最後一個字元

止魚發表於2018-09-20

不BB直接上程式碼

/**
  * @ author: zjf
  * @ description:  
  * @ date: 2018/9/20 20:55
  */
object Test {

  def main(args: Array[String]): Unit = {
    deleteLastCharInstr("abcde")
  }

  def deleteLastCharInstr (s: String) = {
    val rs = s.dropRight(1)
    println(rs)
  }
}

RS:
abcd

相關文章