Aladdin - Scala Bugtracking
[#1299] project: compiler priority: low category: missing feature
submitter assigned to status date submitted
Stephane Martin moved to trac 2007-08-28 17:36:14.0
subject [contrib #773] String.toInt, .toDouble should allow a default parameter
code
object Foo {
   // this is overly verbose
   def getInt(s : String) = try {
     s.toInt
   } catch {
     case e : NumberFormatException => 0
   }

   // I'd much rather write this
   def getInt2(s : String) = s.toInt(0)
}
what happened
n/a
what expected To be able to optionally provide a default value for string-to-primitive conversion methods, much like Option.get.
[back to overview]
Changes of this bug report
Stephane  edited on  2007-08-28 17:36:31.0
Stephane  edited on  2007-08-28 17:36:55.0
Gilles  edited on  2007-08-29 09:56:31.0