Discuss Scratch

teal256
Scratcher
24 posts

Character tabulation is equal to zero

My browser / operating system: Linux, Firefox LibreWolf 99.0, No Flash version detected
The tab character (U+0009), “ ”, is equal to zero.
Screenshot:
https://u.cubeupload.com/teal/Screenshot2022050118.png (I'm still a “new scratcher”, and I can't post images, so paste the link into your browser)
The empty space on the left side of the block contains a tab character.
selfexplanatory
Scratcher
100+ posts

Character tabulation is equal to zero

It always equals it to 0, this is intended, and if it were removed, it would break projects, especially projects detecting if something is a string
teal256
Scratcher
24 posts

Character tabulation is equal to zero

selfexplanatory wrote:

It always equals it to 0, this is intended, and if it were removed, it would break projects, especially projects detecting if something is a string
I don't think that this is intended, because the only other thing equal to 0 is 0. I think that it would fix projects, and not break them. For example, a project I'm working on removes whitespace from a string, but, as a result of this bug, it also removes zeroes from the string.
Kiska-7275
Scratcher
1000+ posts

Character tabulation is equal to zero

try using this
...contains? the second value is the whitespace
or this
letter...of...contains? the second value is the whitespace

Last edited by Kiska-7275 (May 2, 2022 15:23:18)

teal256
Scratcher
24 posts

Character tabulation is equal to zero

Kiska-7275 wrote:

try using this
...contains? the second value is the whitespace
or this
letter...of...contains? the second value is the whitespace
That works, but I still think that the scratch team should fix this bug.
CST1229
Scratcher
1000+ posts

Character tabulation is equal to zero

Apparently this is because greater than/less than checks are used in the compare function and “ ” is less than “0”.

Last edited by CST1229 (May 3, 2022 04:35:47)

mlcreater
Scratcher
1000+ posts

Character tabulation is equal to zero

CST1229 wrote:

Apparently this is because greater than/less than checks are used in the compare function and “ ” is less than “0”.
That should mean:
<0 compare("\t", "0") < 0
but this is false.
That should not mean:
>-1 compare("\t", "-1") > 0
but this is true.

Greater than/less than checks are used only when "// At least one argument can't be converted to a number[, so] Scratch compares strings…”
The behavior in question seems like numeric comparison, not string comparison—these are both true:
=0 compare("\t", "0") === 0 =0.0 compare("\t", "0.0") === 0

Powered by DjangoBB