Different class definitions for value classes and a handle classes?
Mostrar comentarios más antiguos
Is there a difference in the class definition header for handle classes and value classes?
Also I have heard that the behaviour of handle classes is easier to understand for those familiar with Java. Is this true?
Respuesta aceptada
Más respuestas (1)
David Devoy
el 23 de Mzo. de 2017
0 votos
1 comentario
Adam
el 23 de Mzo. de 2017
Yes, Matlab OOP is very much its own beast. Obviously there are high level similarities with other languages (probably other scripting languages like Python are closer, but again I don't program in Python and have only looked at small amounts of code in it).
When I first learned OOP I used that bug pdf document a lot and started out with a nicely self-contained problem where I was clear what class(es) I wanted to help me familiarise.
Having to return obj is logical, but not intuitive for a C++/Java programmer. There is no reason why you have to assign this returned obj back to the one you made the call on - it is copy-by-value after all so you can assign it to a totally new copy if you wish to keep the original prior to the function call for some reason. I do this occasionally though quite rarely and mostly for functions that are explicitly spawning a copy of the object.
Categorías
Más información sobre Function Handles en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!