title: How to make the code simple in kotlin?
body: <p>There many repeated code in Code A, I hope to make it simply, but Code B doesn't work, how can I fix it? Thanks!</p>
  
  <p><strong>Code A</strong></p>
  
  <pre><code>aMDetail?.findByDeviceDef&lt;BluetoothDef&gt;()?.setDevice(mContext)
  aMDetail?.findByDeviceDef&lt;WiFiDef&gt;()?.setDevice(mContext)
  aMDetail?.findByDeviceDef&lt;ScreenDef&gt;()?.setDevice(mContext)
  </code></pre>
  
  <p><strong>Code B</strong></p>
  
  <pre><code>with(aMDetail?){
      findByDeviceDef&lt;BluetoothDef&gt;()?.setDevice(mContext)
      findByDeviceDef&lt;WiFiDef&gt;()?.setDevice(mContext)
      findByDeviceDef&lt;ScreenDef&gt;()?.setDevice(mContext)
  }
  </code></pre>