Project

General

Profile

Feature #6224

Make variables in if/unless conditions available to conditional statements

Added by gcao (Guoliang Cao) about 8 years ago. Updated about 8 years ago.

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

Description

I propose to make below code work

do_something(a) if a = condition

Above code should work exactly same as

if a = condition
do_something(a)
end

If there is a reason behind why the first case does not work, please let me know.

Thank you.
Guoliang Cao


Related issues

Is duplicate of Ruby master - Feature #1141: assignment of variable in "right" if statement failsRejected02/11/2009Actions
Is duplicate of Ruby master - Feature #4965: The problem of "print line if line = DATA.gets"Rejected07/03/2011matz (Yukihiro Matsumoto)Actions

Updated by rosenfeld (Rodrigo Rosenfeld Rosas) about 8 years ago

I'm pretty sure this is already being discussed but I can't remember in what thread/issue.

Updated by gcao (Guoliang Cao) about 8 years ago

I found this issue created 3 years ago. Matz explained the reason behind.

http://bugs.ruby-lang.org/issues/1141

Updated by rosenfeld (Rodrigo Rosenfeld Rosas) about 8 years ago

Exactly. Actually I didn't know about 1141, but I've read about 4965 recently.

Updated by mame (Yusuke Endoh) about 8 years ago

  • Status changed from Open to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)
#5

Updated by matz (Yukihiro Matsumoto) about 8 years ago

  • Status changed from Assigned to Rejected

The reason behind has been explained in #1141. If someone want to change the rule, he need to understand the rational first, then should try persuade me.

Matz.

Also available in: Atom PDF