Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: question about value class 'setter' method
Replies: 2   Last Post: Nov 4, 2009 9:58 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Ian Bell

Posts: 12
Registered: 11/26/08
question about value class 'setter' method
Posted: Nov 3, 2009 11:15 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I am reading through the Matlab documention to understand how classes are implemented. I came across the following statement:

Value Classes. When writing methods that update an object, you must pass back the updated object and use an assignment statement. For example, a value class implementation of a set method for a property requires the object to be returned with the new value set.
A = set(A,'PropertyName',PropertyValue)

This is odd in that it appears to be saying that an instance of the class must be updated/reassigned EVERY single time a 'setter' method is called? For example, assume the class 'MyClass' has a property named 'MyStringProperty' and the method 'setMyStringProperty' which updates this property:
mc = MyClass();
mc = mc.setMyStringProperty( '111' );
mc.setMyStringProperty( '222' );

I come from a C++ background and expect "MyStringProperty' to be set to '222'. The Matlab documentation implies that correct value would be '111'. Can someone clarify how I would expect to call a 'setter' method.

Thanks,

Ian



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2009. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Goodwin College of Professional Studies.