Scala #2 String(複数行の処理)
今日は文字列について確認していこうと思う。。
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
複数行の処理
(String).lines.foreach の使用により複数行の処理が可能!!
object String { def main(args: Array[String]): Unit = { "1\n2\n2\n3".lines.foreach { x => print(x + " ") } //出力結果(1 2 2 3 ) } }
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
少しずつscalaを振り返ろう
Scala #1 Lazyについて - YMChihiroの日記
Scala #2 String(複数行の処理) - YMChihiroの日記