[BUG:1.9] ||= &&= doesn't return rval, but result of method

Redminee$B%W%m%8%’%/%H08$KMh$F$7$^$C$?e(Bissuee$B$rE>Aw$7$^$9!#e(B

---------- e$BE>Aw%a%C%;!<%8e(B ----------
From: Joshua H. [email protected]
e$BF|IUe(B: 2009/08/26 11:01
e$B7oL>e(B: [redmine4ruby-lang:256] [Bug #1996] ||= &&= doesn’t return
rval,
but result of method
To: [email protected]

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

e$B5/I<<Te(B: Joshua H.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: 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”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs