Scala beginner question

Pietro <[email protected]> Wed, 02 Mar 2016 16:39:11 +0000
Newsgroups gmane.comp.lang.scala
Message-ID <[email protected]>
Hi everybody,

I am not even sure this is the right place to ask this beginner
questions nevertheless I do prefer gmane.* to StackOverflow and I wanted
to give to it a try; feel free to point me to the right newsgroup if
this isn't the most proper place.

I have recently started to write a simple project in Scala, I got stuck
in solving a couple of reasonalble simple problems; as many others I am
from a imperative Java/C background and I am striving to change mindset.

The following function should wipe out all the digits and punctuation
characters present in the given string "content", anyway the match
statement never matches where I expect and the string does not get
modified.

Is there a big mistake I haven't noticed ?

  val digitRE       = """[0-9]""".r
  val punctuationRE = """.|;|,|"|:""".r 

  private def transformContent(content : String) : String = {
    val _ret = new StringOps(content)
    _ret.toLowerCase().filter(
      (c) => {
        c match {
          case digitRE(_*)       => false
          case punctuationRE(_*) => false
          case _                 => true
        }
      })
  }

Then comes my next question, I would like to write a loop which reads
from the console user's input and stops when the the user enters a null
value, that is, they presses ENTER without having entered any characters
before it.

This is one of my several attempt to achieve it, it obviously does
not work properly. 

    while ( (path = readLine()) != null)
      println(path)
  }

The only working solution I have got so far is to
throw an exception, something like :

try {
    while (true) {
            if (whatever)
                     throw AllDone
    }

}catch (AllDone) {
      ...
}

Any better ideas ?

-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.