Project

General

Profile

Actions

Bug #800

closed

Problem with Array class

Bug #800: Problem with Array class

Added by Francoys_Proulx (Francois Proulx) almost 17 years ago. Updated over 14 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-core:20158]

Description

=begin
If you test this simple program, you will see why array should be dup on assignment ...

a=1
b=1
c=[a,b]

def foo(x)
  x[0] +=1
  x[1] +=1
end

d = c
e = d
f = e

foo(f)

p c[0],c[1]

=end

Updated by radarek (Radosław Bułat) almost 17 years ago Actions #1

=begin
No it shouldn't. Variables keeps references to objects, not objects itself. It is up to programmer if he wants to pass reference (as ruby do by default) or make clone (duplicate) of it.
=end

Updated by matz (Yukihiro Matsumoto) almost 17 years ago Actions #2

  • Status changed from Open to Rejected

=begin
No, it shouldn't. It will destroy the object model of the language.
=end

Actions

Also available in: PDF Atom