Hi everyone. Currently I'm doing this ```providers...
# announcements
e
Hi everyone. Currently I'm doing this
Copy code
providers.forEachIndexed { index, provider ->
  if (index == 0) {
    whatsNewPanel.setProvider(provider)
  }
  ...
Is there a function/extension which lets me move that
whatsNewPanel.setProvider(provider)
in a separate space? Possibly in the same call chain
m
You can use
firstOrNull
to get the first element of the collection (or null if it is empty) and then
?let
to access that value null safely:
Copy code
providers.firstOrNull()?.let { whatsNewPanel.setProvider(it) }
🤘 1