Actually, Jan's way is probably the best... as if you wrongfully type convert the wrong type, it'll panic (you'll need to know for sure that arr in this instance will always be a boolean). With Jan's way, you're just making a comparison of value... which will work regardless of the type.
On Monday, January 29, 2018 at 1:52:38 PM UTC-6, Trig wrote: > > This... or just specify the type after 'arr' such as: > > if arr.(bool) { > fmt.Println("This is a boolean value") > } > > > On Monday, January 29, 2018 at 5:41:17 AM UTC-6, Jan Mercl wrote: >> >> On Mon, Jan 29, 2018 at 12:36 PM pradam <pradam.pr...@gmail.com> wrote: >> >> > //here its throwing error like: non-boolean condition in if statement >> >> The compiler is right. 'arr' is not a boolean expresion, its type is >> 'interface{}'. Try: https://play.golang.org/p/zwNV9RD2oCs. >> >> -- >> >> -j >> > -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.