Ruby 什么版本开始支持这个语法的?

sevk · December 22, 2021 · Last by HDJ replied at December 23, 2021 · 711 hits

nil and nil.xxx 
=> nil

新语法:

nil &.xxx
=> nil

什么版本开始支持这个语法的,这里没找到 https://rubyreferences.github.io/rubychanges/

Reply to lijunwei

这里提到过

单身狗运算符,没记错的话是 2.3

答案找到了 : https://rubychangelog.com/versions-latest/

搜索 "&." 就有

v2.3.8

我不太喜欢这样的语法,在审视代码的时候总有一种别扭的感觉

You need to Sign in before reply, if you don't have an account, please Sign up first.