Is there a more idiomatic way to write this? ``` ...
# announcements
d
Is there a more idiomatic way to write this?
Copy code
val contentBodyP2MessageKey = template.contentBodyP2MessageKey
        val contentBodyP2MessageArgs = template.contentBodyP2MessageArgs
        if (contentBodyP2MessageKey != null && contentBodyP2MessageArgs != null) {
            val contentBodyP2 =
                messageSource.getMessage(contentBodyP2MessageKey, contentBodyP2MessageArgs(environment), locale!!)
            context.setVariable("contentBodyP2", contentBodyP2)
        }
a
Overall it seems fine to me, but I'd find a way to get rid of that
!!
d
I did. But actually that seems to be a common problem with Kotlin and dealing with Spring 4.x