package main
import (
"fmt"
"reflect"
)
func main() {
array := []interface{}{true,1,"dodda"}
arr:=array[0]
fmt.Println(arr, reflect.TypeOf(arr)) // prints *true bool*
if arr{
fmt.Println("This is a boolean value") //here its throwing error
like: *non-boolean
condition in if statement*
}
}
- Why arr condition is failing in spite of its a boolean value?
- Whats the Difference b/w interface and struct? which is more efficient
to use..?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.