Switch inconsistancy

GARY FORBIS forbisgaryg at msn.com
Wed Jan 7 22:33:33 CST 2009


Here's the test program:
 
x=''if (strcmp(x,''))   printf ("equal\n")else  printf("unequal\n")endif
switch xcase ''  printf ("equal\n")otherwise  printf ("unequal\n")endswitch
x=" "if (strcmp(x," "))   printf ("equal\n")else  printf("unequal\n")endif
switch xcase " "  printf ("equal\n")otherwise  printf ("unequal\n")endswitch
 
Here's the output:
 
x = equalunequalx =  equalequal
 
--------
 
I've gone ahead an purchased a license to MathLab. 
While I like the switch/endswitch construct better I
don't like the results of the first switch statement where '' doesn't work as expected.
MathLab produces the following:
 
>> x='';
>> switch xcase '''equal'otherwise'unequal'end
ans =
equal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www-old.cae.wisc.edu/pipermail/help-octave/attachments/20090108/bb0e6420/attachment.html 


More information about the Help-octave mailing list