Skip to content

Commit

Permalink
Update utils.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Deficuet authored and Deficuet committed Jul 22, 2023
1 parent bfef20d commit 4d2c50e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/kotlin/io/github/deficuet/unitykt/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ fun Collection<Object>.allObjectsOf(vararg type: String): List<Object> {
}

inline fun <reified T: Object> Collection<Object>.safeFindWithPathID(pathId: Long): T? {
return with(first { it.mPathID == pathId }) { if (this is T) this else null }
return find { it.mPathID == pathId }?.let {
if (it is T) it else null
}
}

inline fun <reified T: Object> Collection<Object>.findWithPathID(pathId: Long): T {
Expand Down

0 comments on commit 4d2c50e

Please sign in to comment.