Browse files

Explicit variable type

  • Loading branch information...
1 parent 2a77eed commit b6d7d9923abd0855975057a3fce78baabba601e0 @rightgo09 committed Dec 30, 2012
Showing with 14 additions and 0 deletions.
  1. +12 −0 03-06/TextCounter050.scala
  2. +2 −0 03-06/data.txt
View
12 03-06/TextCounter050.scala
@@ -0,0 +1,12 @@
+import scala.io.Source
+
+val filename: String = args(0)
+val src: Source = Source.fromFile(filename) // オブジェクトを取得
+var charCount: Int = 0
+var lineCount: Int = 0
+val lines: Iterator[String] = src.getLines
+for (line: String <- lines) {
+ charCount += line.length
+ lineCount += 1
+}
+println("文字数 = " + charCount + ", 行数 = " + lineCount)
View
2 03-06/data.txt
@@ -0,0 +1,2 @@
+Hello Wolrd
+Scala Programming Sample

0 comments on commit b6d7d99

Please sign in to comment.