changeset 23135:be2654b2f34f

maint: merge stable to default.
author Rik <rik@octave.org>
date Wed, 01 Feb 2017 21:06:37 -0800
parents 03736526b6d8 (current diff) 01bf5c733de7 (diff)
children 2165993aed7d
files scripts/miscellaneous/cast.m
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/cast.m	Wed Feb 01 20:41:45 2017 -0800
+++ b/scripts/miscellaneous/cast.m	Wed Feb 01 21:06:37 2017 -0800
@@ -20,7 +20,8 @@
 ## @deftypefn {} {} cast (@var{val}, "@var{type}")
 ## Convert @var{val} to data type @var{type}.
 ##
-## @var{val} must be one of the numeric classes:
+## Both @var{val} and @var{type} are typically one of the following built-in
+## classes:
 ##
 ## @example
 ## @group
@@ -52,6 +53,18 @@
 ## @end group
 ## @end example
 ##
+## Programming Note: This function relies on the object @var{val} having a
+## conversion method named @var{type}.  User-defined classes may implement only
+## a subset of the full list of types shown above.  In that case, it may be
+## necessary to call cast twice in order to reach the desired type.
+## For example, the conversion to double is nearly always implemented, but
+## the conversion to uint8 might not be.  In that case, the following code will
+## work
+##
+## @example
+## cast (cast (@var{user_defined_val}, "double"), "uint8")
+## @end example
+##
 ## @seealso{typecast, int8, uint8, int16, uint16, int32, uint32, int64, uint64, double, single, logical, char, class, typeinfo}
 ## @end deftypefn