-
• #3
@Andreas_Rozek, what was the output of your test program?
- length differences
- character differences
How did you compare character by character?
My only explanation would be that the data read is not a string but concatenated to an empty string
.toString()
is applied and makes it what you expect... weird and not really reasonable... but JS is known for doing (sometimes) some conversion... - length differences
-
• #4
That's what looked so weird: "!==" was true (mind the extra "=" which means "without any conversion"), but when comparing lengths and character codes, everything was equal.
Thus, I could
- not compare the outcome of Storage.read with a string, but
- use .length and .charCodeAt of the outcome of Storage.read without any problems and
- compare the outcome of Storage.read with a string after appending to ''
- not compare the outcome of Storage.read with a string, but
-
• #5
Thanks. It actually boils down to this:
>E.toString("this is a test of string compare")==="this is a test of string compare" =false
If you used
!= / ==
then you'd be fine, but Espruino's doing a 'type compare' and it gets fooled by having a 'flat string' and a string. That's a nasty one - should get a fix in for it soon. -
• #6
ohh...VERY good to know!
Thanks a lot!
-
• #7
Ok, just fixed :)
-
• #8
that's been quick, thanks!
Good morning!
I must be completely blind or dumb in a different way, but when I write a string into a file, read it back into another string and then compare both strings with "!==", they are reported as different!
Then, if I compare them character by character, no difference is found (as expected).
Does anybody have a solution for this puzzle?
The gist may be directly loaded and run on a connected watch through the IDE. Here comes the code: