underscoreio/essential-scala

Addition to code (6.4.1)

Closed this issue · 1 comments

6.4.1 Option, Some, and None

def readInt(str: String): Option[Int] =
if(str matches "\\d+" ) Some(str.toInt) else None

Int can be negative. Change regex mask to "-?\\d+"

Another good spot!