title: check empty for option string in scala
body: <p>I want to check for empty string in scala .If the string is empty return an option else return a None</p>
  
  <p><strong>Updated 1</strong></p>
  
  <pre><code> case class Student(name:String,subject:Symbol = Symbol("Default")))
  
    def getStudentName(name :Option[String]):Option[Student]={
       name.flatMap(_ =&gt; Option(Student(name.get)))
    }
  </code></pre>
  
  <p><strong>Updated 2</strong></p>
  
  <p>Scenario 1:    </p>
  
  <pre><code> call 1- print(getStudentName(Option("abc")))//Some(Student(abc))
   Call 2- print(getStudentName(Option("")))//return Some(Student())
  </code></pre>
  
  <p>Scenario 2:</p>
  
  <pre><code>case class Emp(id:Int)
  
    def getEmp(id:Option[String]):Option[Emp]={
      id.flatMap(_ =&gt; Option(Emp(id.get.toInt)))
    }
  
    print(getEmp(Option("123")))
    print(getEmp(Option("")))//gives number format exception 
  </code></pre>
  
  <p>I want to return <code>None</code> when I pass <code>""</code> </p>