title: Scala Value is not a member of Unit
body: <p>iam having small problem with my code, i make the code at java and its works but for some reason it wont work in Scala. any idea ?</p>
  
  <pre><code>def main(args: Array[String]) {
  
      val in = new Scanner(System.in)
      var T: String = null
      var P: String = null
      var cand: String = null
      var pos: Int = 0
      var i: Int = 0
  
      System.out.print("Enter a text string T: ")
      T = in.nextLine()
      System.out.print("Enter a pattern string P: ")
      P = in.next()
      println()
      pos = 0
  
      while (pos &lt;= T.length - P.length) {
        cand = T.substring(pos, pos + P.length)
        if (P == cand) {
          println(T)
          i = 0
          while (i &lt; pos) {
            System.out.print(" ")i += 1 // Error : Value i is not a member of Unit
          }
          println(P)
          println()
        }
        pos += 1
      }
      in.close()
    }
  }
  </code></pre>