You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Coincidental correspondence between variable name and string literal is confusing #3803
let hello = "Здравствуйте";let answer = &hello[0];
The original example has no double quotes. However, the double quotes appear in the text like what I copied. is that on purpose for any reason? Or, is that just a typo?
It may be misleading that the string within the sentence is ”hello”. I don’t think there’s any connection between this sentence and the code sample above. The point of the sentence is that indices on string slices are not allowed.
The string could be changed to: ”…if &”abc”[0] were valid code […]”.
changed the title [-]are double quotes added on purpose?[/-][+]Coincidental correspondence between variable name and string literal is confusing[/+]on Jan 8, 2024
Activity
akauppi commentedon Dec 28, 2023
It may be misleading that the string within the sentence is ”hello”. I don’t think there’s any connection between this sentence and the code sample above. The point of the sentence is that indices on string slices are not allowed.
The string could be changed to: ”…if
&”abc”[0]were valid code […]”.[-]are double quotes added on purpose?[/-][+]Coincidental correspondence between variable name and string literal is confusing[/+]Fix confusion between variable `hello` and string `"hello"`
chriskrycho commentedon Nov 27, 2024
This was indeed confusing, so I changed the string example to be
&"hi"[0]instead of&"hello"[0], so it should no longer be an issue. Thanks!