gojuno / koptional

Minimalistic Optional type for Kotlin that tries to fit its null-safe type system as smooth as possible.
Apache License 2.0
289 stars 21 forks source link

Add None.toString #16

Closed bmaslakov closed 6 years ago

bmaslakov commented 6 years ago

I often use this class for debugging, and calling something like println("sessionId=$optional") gives this:

sessionId=com.gojuno.koptional.None@7ce026d3

Why don't we override toString? :)

sessionId=None
bmaslakov commented 6 years ago

As a side note, it'd be also great to have Some(123) instead of Some(value=123)

artem-zinnatullin commented 6 years ago

I guess the only use case where com.gojuno.koptional.None@7ce026d3 is useful is dealing with scenarios like https://youtrack.jetbrains.com/issue/KT-14540 when you accidentally end up having multiple instances of object

But I'd still merge this PR :)

bmaslakov commented 6 years ago

Fixed the line separator and added a cleaner version of Some.toString. As for KT-14540, I think the proper workaround would be to add None.equals(other) = other is None, but I think it is really out of scope for this PR.

bmaslakov commented 6 years ago

Did my best :)

artem-zinnatullin commented 6 years ago

@ming13 @nostra13 PTAL

artem-zinnatullin commented 6 years ago

MAYBE WE EVEN NEED TO BUMP MAJOR VERSION