Actions
Bug #10778
closed`defined?(expr)` should be equivalent to `defined? (expr)` not `(defined? expr)`
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
Description
defined? is an operator not a method, its operand is defined as the expressions to its right.
It does not even require a space: defined?a
So defined?(a)
should be equivalent to defined? (a)
instead of (defined? a)
Updated by nobu (Nobuyoshi Nakada) almost 10 years ago
- Status changed from Open to Feedback
- Priority changed from Normal to 3
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
There isn't a description of the actual problem caused by this behavior, but I'm guessing, it is something like this:
defined? a && defined? b # defined?(a && defined? b)
# => "expression"
defined? (a) && defined? (b) # defined?((a) && defined? (b))
# => "expression"
defined?(a) && defined?(b) # (defined?(a)) && (defined?(b))
# => nil
I'm reasonably confident changing the last example to be parsed as the first two examples would break existing code and would go against the expectations of most Ruby programmers.
Updated by nobu (Nobuyoshi Nakada) over 5 years ago
- Status changed from Feedback to Rejected
In Ruby, a space before an opening parenthesis often has significant meanings.
Combining defined?(a)
higher than &&
is considered reasonable.
Actions
Like0
Like0Like0Like0