Is there any specific reason why NonEmptySet and N...
# arrow-contributors
p
Is there any specific reason why NonEmptySet and NonEmptyList have a custom toString representation rather than delegating to the underlying collection (and most likely using the standard
AbstractCollection.toString()
)?
💯 1
a
my thought there was that if you don't have something that tells you that you are using a NonEmptySomething, you may be a bit lost when debugging and logging. Maybe the default implementation of
toString
is ok in many cases, but it you wrap some custom collection implementation, it may get a bit confusing
p
Makes sense - colleague just had a test fail when switching from listOf to nonEmptyListOf - then again, the test shouldn't have been depending on toString 🤣
😅 1
o
For me, @Alejandro Serrano.Mena it's exactly the opposite. My logging very frequently is read by users that don't understand, nor care, what a NonEmptyList is. It's an implementation detail. What I am interested in when logging is the contents, not the type. With the same mindset, for all of us it's okay that logging an
Int
does not print
Int(42)
but just
42
and nobody complains the type is missing... 😉