| CS 1371 Dept. Presents: |
| ASSIGNIN | |
|---|---|
| Definition |
Assigns a variable in workspace. Whenever you change the data contained in an object, assignin(...) must be used to force the changes you actually made in your local copy of the object back into the caller's copy. This puts some restrictions on calling methods that expect to change the
content of an object. The object must be supplied to the method call as a simple
variable reference, rather than a Cell array or structure reference that
assignin(...) cannot decipher to update the object. |
| Example |
function
setBalance(acct, amount)
acct.balance = amount;
assignin('caller',
inputname(1), acct);
ASSIGNIN in this method assigns the new balance to the object acct. Without it, the balance will not be modified. |