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

Removes some extension functions that are not a cohesive part of this library #74

Closed popematt closed 2 years ago

popematt commented 2 years ago

Issue #, if available:

None

Description of changes:

The Ion Element Kotlin library includes some extension functions that are not specific to Ion. The concept of tag, head, and tail are not specific to Ion, and are not cohesive with the rest of this library.

Clients can still re-implement these extension functions if necessary. However, they shouldn't need to because there are KotlinStdlib functions (first() and drop(n: Int)) that can accomplish the same thing. For example:

// To assume and get the symbol text of the first element of a sequence (aka the "tag")
val tag = mySeqElement.values.first().symbolValue

// To get the head of a sequence
val head = mySeqElement.values.first()

// To get the tail of a sequence
val tail = mySequence.values.drop(1)

// To get the head of a List<AnyElement>
val headOfList = anyElementList.first()

// To get the tail of a List<AnyElement>
val tailOfList = anyElementList.drop(1)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.