amazon-ion / ion-element-kotlin

IonElement is an immutable in-memory representation of the Ion data format. IonElement's API is idiomatic to Kotlin.
Apache License 2.0
8 stars 8 forks source link

Add `isNotNull` for `IonElement` Interface #78

Open lziq opened 2 years ago

lziq commented 2 years ago

For IonElement interface, currently we have isNull method to check if the value is null. Can we also add the method isNotNull to provide better ergonomics for users to write code?

popematt commented 2 years ago

For anyone who wants this, as a workaround for now, you can create your own extension function like this:

fun IonElement.isNotNull(): Boolean = !isNull()
AndrewChildre commented 2 years ago

Did you just want this defined in the interface? I would do something like

public val isNotNull: Boolean

I'm a rookie < 1 year at my job just looking to contribute to some open source projects for some more experience. The pace of dev is slow where I work and I want to build my skills faster. Just rying to help. Thanks

popematt commented 2 years ago

Hi, thanks for your interest!

Did you just want this defined in the interface?

Something that is unstated but implied is that classes which implement IonElement would also need an implementation of isNotNull. (Otherwise the library won't compile.)

We would like for this change to be backwards compatible, so the implementation should be a default implementation in IonElement since consumers of the library can create their own implementations of IonElement.

Feel free to follow up with any more questions you may have—I'm more than happy to help.

AndrewChildre commented 2 years ago

Thanks for getting back to me. I'm going to dig into this to see if I can understand it some more.