Project

General

Profile

Bug #1996

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

Added by joshbuddy (Joshua Hull) about 11 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
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

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

Updated by yugui (Yuki Sonoda) about 11 years ago

=begin
Redmineプロジェクト宛に来てしまったissueを転送します。

---------- 転送メッセージ ----------
From: Joshua Hull redmine@ruby-lang.org
日付: 2009/08/26 11:01
件名: [redmine4ruby-lang:256] [Bug #1996] ||= &&= doesn't return rval,
but result of method
To: redmine4ruby-lang@qwik.jp

Bug #1996: ||= &&= doesn't return rval, but result of method
http://redmine.ruby-lang.org/issues/show/1996

起票者: Joshua Hull
ステータス: Open, 優先度: Normal

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"


http://redmine.ruby-lang.org

--
archive-> http://qwik.jp/redmine4ruby-lang/146.html
ML-> redmine4ruby-lang@qwik.jp

=end

#2

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r24757.
=end

Also available in: Atom PDF