Skip to content

Commit

Permalink
feat: Iterable#applyForEach, bump ver 16
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbker committed Oct 29, 2023
1 parent 3b8f10e commit 6c539cf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Maven
<dependency>
<groupId>gg.flyte</groupId>
<artifactId>twilight</artifactId>
<version>1.0.15</version>
<version>1.0.16</version>
</dependency>
```

Expand All @@ -29,14 +29,14 @@ maven {
url "https://repo.flyte.gg/releases"
}
implementation "gg.flyte:twilight:1.0.15"
implementation "gg.flyte:twilight:1.0.16"
```

Gradle (Kotlin DSL)
```kotlin
maven("https://repo.flyte.gg/releases")

implementation("gg.flyte:twilight:1.0.15")
implementation("gg.flyte:twilight:1.0.16")
```

Certain features of Twilight require configuration, which can be done via the Twilight class. To setup a Twilight class instance, you can use the `twilight` method as shown below:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "gg.flyte"
version = "1.0.15"
version = "1.0.16"

repositories {
mavenCentral()
Expand Down
14 changes: 14 additions & 0 deletions src/main/kotlin/gg/flyte/twilight/extension/Collection.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gg.flyte.twilight.extension

/**
* Applies the specified action to each element in the iterable.
*
* This extension function iterates through the elements of the iterable and
* applies the given action to each element, allowing for in-place modification
* or transformation of the elements.
*
* @param action The lambda function to apply to each element.
*/
inline fun <T> Iterable<T>.applyForEach(action: T.() -> Unit) {
forEach { it.action() }
}
10 changes: 10 additions & 0 deletions src/test/kotlin/gg/flyte/twilight/CollectionTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gg.flyte.twilight

import gg.flyte.twilight.extension.applyForEach

fun main() {
val list = listOf("test", "asd", "34534534asd", "asdas2sd")
list.applyForEach {
println(this)
}
}

0 comments on commit 6c539cf

Please sign in to comment.