String of digits.

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
jassing
Posts: 94
Joined: 16 Jul 2017 01:42
Location: SF Bay Area

String of digits.

Post by jassing » 09 Dec 2019 03:37

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}";
}

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: String of digits.

Post by Desmanto » 09 Dec 2019 06:30

: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}");
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
jassing
Posts: 94
Joined: 16 Jul 2017 01:42
Location: SF Bay Area

Re: String of digits.

Post by jassing » 10 Dec 2019 11:08

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.

Post Reply