CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
2
Task/Character-codes/Go/character-codes-1.go
Normal file
2
Task/Character-codes/Go/character-codes-1.go
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fmt.Println('a') // prints "97"
|
||||
fmt.Println('π') // prints "960"
|
||||
16
Task/Character-codes/Go/character-codes-2.go
Normal file
16
Task/Character-codes/Go/character-codes-2.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// yes, there is more concise syntax, but this makes
|
||||
// the data types very clear.
|
||||
var b byte = 'a'
|
||||
var r rune = 'π'
|
||||
var s string = "aπ"
|
||||
|
||||
fmt.Println(b, r, s)
|
||||
for _, c := range s { // this gives c the type rune
|
||||
fmt.Println(c)
|
||||
}
|
||||
}
|
||||
3
Task/Character-codes/Go/character-codes-3.go
Normal file
3
Task/Character-codes/Go/character-codes-3.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
b := byte(97)
|
||||
r := rune(960)
|
||||
fmt.Printf("%c %c\n%c %c\n", 97, 960, b, r)
|
||||
3
Task/Character-codes/Go/character-codes-4.go
Normal file
3
Task/Character-codes/Go/character-codes-4.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fmt.Println(string(97)) // prints "a"
|
||||
fmt.Println(string(960)) // prints "π"
|
||||
fmt.Println(string([]rune{97, 960})) // prints "aπ"
|
||||
Loading…
Add table
Add a link
Reference in a new issue