Project

General

Profile

Feature #12263

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

Ruby 2.3 introduced the `&.` &. safe-navigation operator. I'd like to propose a `&&.` &&. operator which would be shorthand for: 

 ~~~ruby 
 foo && foo.method 
 ~~~ 

 Unlike `&.`, &., this does not continue the chain if the variable evaluates to `false`. false. This would give the following result: 

 ~~~ruby 
 false&.class         # => FalseClass 
 false&&.class        # => false 

 false&.inexisting    # => raises NoMethodError 
 false&&.inexisting # => false 
 ~~~

Back