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
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!
The text was updated successfully, but these errors were encountered:
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:
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:
Your insight about comparing "🐻" to "17" was quite clever, and it might help other students understand the concept better too!
The text was updated successfully, but these errors were encountered: