原创转载请注明出处:http://agilestyle.iteye.com/blog/2333013

 

package org.fool.scala.basic

object ScalaPrintArgs {
  def formatArgs(args: Array[Any]) = args.mkString("\n")

  def main(args: Array[String]): Unit = {
    println(Array(1, 2, "a", "b", 0.23, 0.45))
    println(formatArgs(Array(1, 2, "a", "b", 0.23, 0.45)))

    val res = formatArgs(Array("zero", "one", "two"))
    // Scala's assert method checks the passed Boolean and if it is false, throws AssertionError.
    // If the passed Boolean is true, assert just returns quietly.
    assert(res == "zero\none\ntwo")
  }
}

Console Output 

Scala Print Args
 

 

相关文章:

  • 2022-12-23
  • 2021-12-11
  • 2021-06-03
  • 2022-12-23
  • 2021-12-16
  • 2021-10-28
  • 2021-07-24
  • 2021-07-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-01
  • 2022-01-19
  • 2021-12-07
  • 2021-11-20
  • 2022-02-18
相关资源
相似解决方案