how may I rewrite this more functional? ``` ...
# codereview
e
how may I rewrite this more functional?
Copy code
// Request several formats, the first found will be used
            for (request in requestFormats)
                for (avail in availFormat)
                    if (avail.format == request && avail.colorSpace == requestColorSpace)
                        return avail
            
            // If none of the requested image formats could be found, use the first available
            return availFormat[0]
l
availFormat.firstOrNull { it.format in requestFormats && it.colorSpace == requestColorSpace } ?: availFormat[0]
?
e
nice, I was missing the
in
in my head, thanks!