DEV Community

Discussion on: More easily leveraging bool's from a ptr

Collapse
 
maxatome profile image
Maxime Soulé

You can use this code:

isItTrue := boolPtr != nil && *boolPtr

or use a helper function, as it will probably be inlined by the compiler.
Note that your isNilbool function is useless. Using a function to do a simple == is overkill.

Collapse
 
nickhuanca profile image
Nick Huanca

thanks for the helpful feedback Maxime - I'll definitely adjust my approach :)