Empty() VS IsEmpty()

Hi all,
For my tree data structure I want to create a method that returns true if the tree has no elements.

I already have a Clear() method to forcefully delete everything inside the tree. Which name should I use Empty or IsEmpty, what is more idiomatic to Go ?

Somehow Empty seems like a bad name, due to possible confusion, anyone else think the same ?

How about a Len() function like Go’s other containers (e.g. bytes.Buffer, container/list.List, container/ring.Ring, etc.). It’s more common to compare this to zero than to have an (Is)Empty function, I think.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.