Project

General

Profile

Actions

Bug #1996

closed

||= &&= doesn't return rval, but result of method

Added by joshbuddy (Joshua Hull) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
Backport:
[:]

Description

=begin
Inconsistent behvaiour introduced in Ruby 1.9.1 with compound assignment operators.

o = Object.new
=> #Object:0x00000100975a80
def o.foo=(x); x * 2 end
=> nil
def o.foo; nil end
=> nil
o.foo = 1
=> 1
o.foo ||= 1
=> 2
RUBY_VERSION
=> "1.9.2"
RUBY_RELEASE_DATE
=> "2009-07-24"
RUBY_REVISION
=> 24260

In ruby 1.8

o = Object.new
=> #Object:0xe6c8
def o.foo=(x); x * 2 end
=> nil
def o.foo; nil end
=> nil
o.foo = 1
=> 1
o.foo ||= 1
=> 1
RUBY_VERSION
=> "1.8.7"
=end


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #2050: Abbreviated Assignment Operators No Longer Return rvalueClosed09/05/2009Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0