Saturday 4 September 2021

Go Rune Type

 The type rune is an alias for type int32. The rune literals are an integer value.

If you store string value in rune literal, it will provide the ASCII value of the character. For example, the rune literal of 'A' will be 65.

Go Rune Type Example

  1. package main    
  2. import(    
  3.    "fmt"    
  4.    "reflect"    
  5. )    
  6. func main(){    
  7.    rune := 'A'    
  8.    fmt.Printf("%d \n", rune)    
  9.    fmt.Println(reflect.TypeOf(rune))    
  10. }   

Output:

65
int32

No comments:

Post a Comment