DEV Community

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

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.

nickhuanca profile image
Nick Huanca Author

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