Project

General

Profile

Actions

Feature #11534

closed

Circular assignment / method shadowing unexpected behavior

Added by tsmith (Tim Smith) over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:<unknown>]

Description

def foo
  1
end

puts foo + 1

bar = foo + 1
puts bar

foo = foo + 1
puts foo
# EXPECTED
2
2
2
# ACTUAL
2
2
undefined method `+' for nil:NilClass (NoMethodError)
Actions #1

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Description updated (diff)
  • Status changed from Open to Rejected

Assignment statements make variables.

Actions #2

Updated by tsmith (Tim Smith) over 8 years ago

  • Tracker changed from Bug to Feature

Then consider it a feature request ;) First evaluate the righthand side, then make the variable.

Actions

Also available in: Atom PDF

Like0
Like0Like0