Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Boolean-values/Go/boolean-values.go
Normal file
26
Task/Boolean-values/Go/boolean-values.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var n bool = true
|
||||
fmt.Println(n) // prt true
|
||||
fmt.Printf("%T\n", n) // prt bool
|
||||
n = !n
|
||||
fmt.Println(n) // prt false
|
||||
|
||||
x := 5
|
||||
y := 8
|
||||
fmt.Println("x == y:", x == y) // prt x == y: false
|
||||
fmt.Println("x < y:", x < y) // prt x < y: true
|
||||
|
||||
fmt.Println("\nConvert String into Boolean Data type\n")
|
||||
str1 := "japan"
|
||||
fmt.Println("Before :", reflect.TypeOf(str1)) // prt Before : string
|
||||
bolStr, _ := strconv.ParseBool(str1)
|
||||
fmt.Println("After :", reflect.TypeOf(bolStr)) // prt After : bool
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue