Mercurial > octave
changeset 32905:81d1512a47cb
maint: Merge stable to default.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Thu, 01 Feb 2024 23:33:51 -0500 |
parents | 9aeb66a38955 (current diff) cf43680cd221 (diff) |
children | 3904d7116c8c b815641a6bcc |
files | libinterp/parse-tree/pt-eval.cc |
diffstat | 1 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc Thu Feb 01 15:54:10 2024 -0800 +++ b/libinterp/parse-tree/pt-eval.cc Thu Feb 01 23:33:51 2024 -0500 @@ -2290,6 +2290,31 @@ @result{} 6 @end group @end example + +Programming notes: +@enumerate +@item +The @code{end} keyword cannot be used within @code{subsref}, +@code{subsasgn}, or @code{substruct} for manual indexing operations. + +@item +For custom classes, to enable use of @code{end} in indexing expressions it +must be overloaded with a function definition such as: + @example + @group + function last_index = end (obj, end_dim, ndim_obj) + if (end_dim == ndim_obj) + last_index = prod (size (obj)(end_dim:ndim_obj)); + else + last_index = size (obj, end_dim); + endif + endfunction + @end group + @end example +For more information see +@ref{Object Oriented Programming, , Object Oriented Programming}. +@end enumerate + @seealso{for, parfor, if, do, while, function, switch, try, unwind_protect} @end deftypefn */) {