作者:月星名店_882 | 来源:互联网 | 2023-09-15 15:23
Icurrentlyhaveapieceofcodethatlookslike:我目前有一段代码如下:ifmatchrequest.path.match(\A\(?
I currently have a piece of code that looks like:
我目前有一段代码如下:
if match = request.path.match(/\A\/(?(?!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?
有没有办法使用安全导航操作符(在2.3.0中引入),以避免这种情况有条件?
4 个解决方案