Project

General

Profile

Feature #6270

add "??a" support for "not defined?(a) or a.nil?"

Added by jacksonwillis (Jackson Willis) about 5 years ago. Updated about 5 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
[ruby-core:44184]

Description

It would work like this:

??foo #=> nil

foo = nil

??foo #=> nil

foo = 3

??foo #=> true

Not sure if this would be useful, just a suggestion.

History

#1 [ruby-core:44187] Updated by jacksonwillis (Jackson Willis) about 5 years ago

So ??foo' is basically a macro fornot defined?(foo) or foo.nil?'.

#2 [ruby-core:44195] Updated by drbrain (Eric Hodel) about 5 years ago

=begin
This syntax seems too similar to the ?a character string syntax

Currently ?a returns "a", so how would the parsing of this expression change:

true ??a:?b

Which currently returns "a", or:

question_method??a

Which currently parses the same as:

question_method? "a"
=end

#3 [ruby-core:44204] Updated by matz (Yukihiro Matsumoto) about 5 years ago

  • Status changed from Open to Rejected

As Eric pointed out, it's conflicting existing syntax. I don't reject the basic idea (though I am excited), so try again with new syntax if you really want this.

Matz.

Also available in: Atom PDF