Re: Issue on newArray macro function

Posted by Michael Schmid on
URL: http://imagej.273.s1.nabble.com/Issue-on-newArray-macro-function-tp5019886p5019889.html

On 16/01/2018 13:51, Herbie wrote:
 > Did you try:
 >
 > a = newArray( ""+5+1, 5+2 );
 > Array.print(a);


Hi Herbie,

yes, your solution works, but then the first array element is a String,
not a number. See the difference here:

   a = newArray( ""+5+1, 5+2 );
   Array.print(a);
   print(a[0]+1);   // 61, String concatenation
   print(a[1]+1);   // 8, arithmetics 5+2+1
   print(a[0]-1);   // error (cant do the calculation with a String)

Michael

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html