octave-maintainers
[Top][All Lists]
Advanced

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

Re: Another request for classdef test in Matlab


From: Michael Goffioul
Subject: Re: Another request for classdef test in Matlab
Date: Sat, 5 Jan 2013 18:15:14 -0500

On Sat, Jan 5, 2013 at 5:26 PM, Philip Nienhuis <address@hidden> wrote:
Michael Goffioul wrote:
Last test request. With the following class:

classdef ClassA
   properties
     x = 1;
   end
   methods
     function obj = ClassA (x)
       if nargin > 0
         obj.x = x;
       end
     end
   end
end

Execute the following at the prompt:

(Double \r\n sequences folded into one except above next command - I hate ML's wasteful use of screen real estate)
ML r2013a (8.1)

>> a(2,2) = ClassA(2)

a =
  2x2 ClassA array with properties:
    x

>> b = a

b =
  2x2 ClassA array with properties:
    x

>> c = a(1,1)
c =
  ClassA with properties:

    x: 1

>> c.x = 3
c =
  ClassA with properties:

    x: 3

>> a(1,1).x, b(1,1).x, c.x
ans =
     1
ans =
     1
ans =
     3

     >> a(1,1).x = 4

a =
  2x2 ClassA array with properties:
    x

    >> a(1,1).x, b(1,1).x, c.x
ans =
     4
ans =
     1
ans =
     3
>>

Can you run the same tests when ClassA inherits from handle? That is:

classdef ClassA < handle
   properties
     x = 1;
   end
   methods
     function obj = ClassA (x)
       if nargin > 0
         obj.x = x;
       end
     end
   end
end

Michael.


reply via email to

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