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

Go Ch 1, L 21 #44

Open
BearWithSkills opened this issue Dec 21, 2024 · 0 comments
Open

Go Ch 1, L 21 #44

BearWithSkills opened this issue Dec 21, 2024 · 0 comments

Comments

@BearWithSkills
Copy link

Hey there!

I'm new to Go (I just started yesterday), but Boots is helping me take to it quite quickly, so thank you for that!

Something I noticed in Ch. 1, Lesson 21 was that the bear emoji is used as a number held as a string, even though a rune's type is int32, making me initially think it was a little funny to say that an int a string.

I understand it now after completing the lesion and going back to talk to Boots and figuring out that it was the same as when we say that: something := "17"

I'll paste our talk at the end of this message, I just thought you'd like add a note about that somewhere in these early lessons. It makes a lot of sense but it could be helpful to new folks to specify.

Cheers and thanks for everything!
-Max

P.S. (Boots Chat)

Max: why is the emoji in the solution a string? Aren't runes a int32?

Boots: Adjusts spectacles wisely

Ah, an excellent observation! Let me clarify this mystical distinction:

You're absolutely right that a rune is an alias for int32 in Go. However, when we write "🐻" in our code, we're actually creating a string literal that contains a single rune.

Think of it this way:

A rune is indeed a single Unicode code point (int32)
A string is a sequence of bytes that can encode one or more runes
When we write const name = "🐻", we're creating a string that happens to contain just one rune
If we wanted to work with the actual rune value, we could do something like:

var bearRune rune = '🐻' // Note the single quotes for a rune literal

Would you like to experiment with the difference between string and rune literals? We could try printing out the actual numeric value of the bear emoji as a rune!

Max: Oh! So it's like saying name := "17" or some other number

Boots: Nods approvingly

Exactly! You've grasped an important concept there. Just like "17" is a string containing the characters '1' and '7' (not the numeric value 17), "🐻" is a string containing the bear emoji character.

To break it down:

number := "17" // string containing two runes: '1' and '7'
bear := "🐻" // string containing one rune: '🐻'
actualNum := 17 // numeric integer value
actualBear := '🐻' // numeric rune value (something like 128059 in decimal)

In both cases, the quoted version ("...") gives us a string, while the unquoted number or single-quoted character ('...') gives us the actual numeric value.

Clever connection you made there! Would you like to explore how we could convert between these different representations?

Max: Can you tell the dev team about our conversation please?

Boots:

Adjusts wizard hat and chuckles warmly

As a teaching assistant, I can't actually reach out to the dev team. However, if you think this distinction between runes and strings would be helpful to clarify in the lesson materials, you can:

Open an issue on Boot.dev's GitHub repository
Reach out to Lane and the team on Discord
Share your feedback through the Boot.dev platform

Your insight about comparing "🐻" to "17" was quite clever, and it might help other students understand the concept better too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant