title: How to merge two Option[String] variables into one when using flatMap in Scala?
body: <p>I have the following class:</p>
  
  <pre><code>case class Profile(email: Option[String],
                     firstName: Option[String],
                     lastName: Option[String],
                     fullName: Option[String])
  </code></pre>
  
  <p>Now I want to remove the <code>fullName</code> attribute because it's redundant. However, I have a method in my class <code>User</code> which returns the <code>fullName</code>:</p>
  
  <pre><code>case class User(id: UUID, profiles: List[Profile]) {
  // Skipped some lines
    def fullName(loginInfo:LoginInfo) = profileFor(loginInfo).flatMap(_.fullName)
  }
  </code></pre>
  
  <p>Now I am trying to replace the <code>.flatMap(_.fullName)</code> part with a concatenation of <code>firstName</code> + <code>lastName</code>. How can this be done? Do I need make a new <code>Option[String]</code>, like this:</p>
  
  <pre><code>def fullName(loginInfo:LoginInfo) = {
    val firstName = profileFor(loginInfo).flatMap(_.firstName)
    val lastName = profileFor(loginInfo).flatMap(_.lastName)
    val fullName : Option[String] = Some(firstName + " " + lastName)
    fullName
  }
  </code></pre>