Page 1 of 1

String of digits.

Posted: 09 Dec 2019 03:37
by jassing
What's the proper way to do this?
In my head, it should be s="0 1 2 3 4 5 6 7 8 9 10"
But Automagic says s=55.0

Code: Select all

s="0";
for (i in [1 to 10]) {
  s = s + "\t " + i;
}

Code: Select all

s="0";
for (i in [1 to 10]) {
  s = s + "\t {i}";
}

Re: String of digits.

Posted: 09 Dec 2019 06:30
by Desmanto
:lol: Another javascript joke (since Automagic is heavily based on javascript and java). Reminded me of this
Image


The proper method is to use concat(), this will ensure string concatenation, instead of unexpected variable type coercion.

Code: Select all

s = "0";
for(i in [1 to 10])
  s = concat(s, " {i}");

Re: String of digits.

Posted: 10 Dec 2019 11:08
by jassing
Yea! Fuck math & logic! That's fuckin' funny! Literally lol'd... Thanks.

Thanks for concat() I was so focused on finding a str() or toString()...

Thanks.