Kotlin convert List to vararg : <p>I have input data of type <code>List&lt;UnitWithComponents&gt;</code> </p>

<pre><code>class UnitWithComponents {
    var unit: Unit? = null
    var components: List&lt;Component&gt; = ArrayList()
}
</code></pre>

<p>I want to convert the data to a <code>vararg</code> of <code>Unit</code></p>

<p>Currently I am doing <code>*data.map { it.unit!! }.toTypedArray()</code>. Is there a better way to do it?</p>
