Kotlin: Apply vs With
<p>What is the difference between with and apply. From what I know the following code does the same thing:</p>

<pre><code>swingElement.apply {
    minWidth = ENABLED_COLUMN_WIDTH
    maxWidth = ENABLED_COLUMN_WIDTH
    preferredWidth = ENABLED_COLUMN_WIDTH
}
with(swingElement) {
    minWidth = ENABLED_COLUMN_WIDTH
    maxWidth = ENABLED_COLUMN_WIDTH
    preferredWidth = ENABLED_COLUMN_WIDTH
}
</code></pre>

<p>Is there any difference and should I use one over the other?
Also, are there some cases where one would work and the other won't?</p>