octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #46660] object array writing into class member


From: anonymous
Subject: [Octave-bug-tracker] [bug #46660] object array writing into class member alters another class member
Date: Thu, 10 Dec 2015 17:59:21 +0000
User-agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0

URL:
  <http://savannah.gnu.org/bugs/?46660>

                 Summary: object array writing into class member alters
another class member
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Thu 10 Dec 2015 05:59:20 PM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.0.0
        Operating System: GNU/Linux

    _______________________________________________________

Details:

create a simple class with two integer attributes:

classdef testclass
   properties
    x
    y
   end
end

now create an object array of two of those objects and write an integer into x
and after that into y. once you have written into y the integer previously
stored in x is gone:

>> clear all;
>> clear classes;
>> a(1)=testclass;
>> a(2)=testclass;
>> a(2).x = 123;
>> display(a(2).x);
 123
>> display(a(2).y);
[](0x0)
>> a(2).y = 321;
>> display(a(2).x);
[](0x0)  <----- writing into a(2).y has altered a(2).x
>> display(a(2).y);
 321

if the statement is repeated with a non array everything is fine:
>> clear all;
>> clear classes;
>> b=testclass;
>> b.x = 123;
>> b.y = 321;
>> display(b.x)
 123 <----- writing into b.y hasn't altered b.x
>> display(b.y)
 321

the behaviour is different to matlab - and i suppose writing an attribute
member should no alter or reset any other attribute members.






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?46660>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]