title: Get Option according object value
body: <p>I have this object:</p>
  
  <pre><code>case class Student(name: String, dateTime: DateTime)
  </code></pre>
  
  <p>Inside this function i get Student <code>object</code> but the <code>DateTime</code> is sometimes <code>null</code> and sometimes not:</p>
  
  <pre><code>def foo(student: Student): Unit = {
  
  }
  </code></pre>
  
  <p>This is new function that gets <code>Option[DateTime]</code></p>
  
  <pre><code>def foo2(option: Option[DateTime]): Unit = {
  
  }
  </code></pre>
  
  <p>So when call <code>foo2</code> i need to check first if my <code>DateTime</code> is <code>null</code> and then call <code>foo2(None)</code> or <code>DateTime</code> is not <code>null</code> and call <code>Some(student)</code>.</p>
  
  <p>So my question is: instead if using this:</p>
  
  <pre><code>def foo(student: Student): Unit = {
  
     if (student == null) foo2(None)
     else foo2(Some(student))
  }
  </code></pre>
  
  <p>Any idea how to determine the <code>student</code> value and send it to <code>foo2</code> function without using <code>if-else</code> ?</p>