I currently have a piece of code that looks like:
if match = request.path.match(/\A\/(?<slug>(?!admin|assets)\w+)/)
match[:slug]
end
Is there a way to use the safe navigation operator (introduced in 2.3.0) to avoid this if
conditional?
Just use the ordinary (non-sugar) form.
request.path.match(/\A\/(?<slug>(?!admin|assets)\w+)/)&.[](:slug)