Project

General

Profile

Actions

Feature #6270

closed

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

Added by jacksonwillis (Jackson Willis) over 12 years ago. Updated over 12 years ago.

Status:
Rejected
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.

Updated by jacksonwillis (Jackson Willis) over 12 years ago

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

Updated by drbrain (Eric Hodel) over 12 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

Updated by matz (Yukihiro Matsumoto) over 12 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0