Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coincidental correspondence between variable name and string literal is confusing #3803

Open
taitung opened this issue Dec 28, 2023 · 1 comment

Comments

@taitung
Copy link

taitung commented Dec 28, 2023

...if &"hello"[0] were valid code that returned the byte value, it would return 104, not h.

In chapter 8, section 8.2 shows an example of the indexing of a string as follows.

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?

@akauppi
Copy link

akauppi commented 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 […]”.

@carols10cents carols10cents changed the title are double quotes added on purpose? Coincidental correspondence between variable name and string literal is confusing Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants