Scala Print Args
原创转载请注明出处: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