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: Philip Nienhuis
Subject: Re: Another request for classdef test in Matlab
Date: Sat, 05 Jan 2013 23:26:39 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 SeaMonkey/2.0.6

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
>>


reply via email to

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