changeset 19101:4fd271cd9b37

deal.m: Document using interpreter, rather than deal, for comma separated lists. deal.m: Document using interpreter, rather than deal, for comma separated lists. Add input %!error validation tests.
author Rik <rik@octave.org>
date Mon, 01 Sep 2014 08:00:05 -0700
parents f7c524595a71
children be8a12acb20a
files scripts/general/deal.m
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/general/deal.m	Mon Sep 01 07:58:31 2014 -0700
+++ b/scripts/general/deal.m	Mon Sep 01 08:00:05 2014 -0700
@@ -54,6 +54,26 @@
 ## @example
 ## a = b = c = x;
 ## @end example
+##
+## Programming Note: @code{deal} is often used with comma separated lists
+## derived from cell arrays or structures.  This is unnecessary as the
+## interpreter can perform the same action without the overhead of a function
+## call.  For example,
+##
+## @example
+## @group
+## c = @{[1 2], "Three", 4@};
+## [x, y, z ] = c@{:@}
+## @result{}
+##    x =
+##    
+##       1   2
+##    
+##    y = Three
+##    z =  4
+## @end group
+## @end example
+## @seealso{cell2struct, struct2cell, repmat}
 ## @end deftypefn
 
 ## Author: Ariel Tankus
@@ -83,3 +103,6 @@
 %! assert (a, 1);
 %! assert (b, 1);
 
+%!error deal ()
+%!error <nargin . 1 and nargin != nargout> y = deal (1, 2)
+