unicode.ToTitle is returning an int instead of a rune

Hello guys,
I’m just starting with Go, and while checking the Unicode module, I did this:

rune_2 := ‘b’
result := unicode.ToTitle(rune_2)

As I understand according to the official documentation here.

I should be getting “B” as returned value, but I am getting 66 (int32 value) instead.
I really don’t understand why this is happening since I’m following the same logic used in the official example, I even opened the source code and this method should return a rune.

1 Like

The rune type is just an alias type rune = int32.

An alias declaration has the form

type T1 = T2

as opposed to a standard type definition

type T1 T2

An alias declaration doesn’t create a new distinct type different from the type it’s created from. It just introduces an alias name T1 , an alternate spelling, for the type denoted by T2 .

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.