Skip to content

String.toInt, .toDouble should allow a default parameter #16

@scabug

Description

@scabug

Aladdin: [http://scala-webapps.epfl.ch/bugtracking/bugs/displayItem.do?id=1299 bug 1299], [http://scala-webapps.epfl.ch/bugtracking/contribs/display.do?id=773 contrib 773]

== 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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions