Created
August 15, 2016 23:51
-
-
Save DenWav/8ce0a66926a480a8f6bf7574d56a4e26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fun <T> MutableIterable<T>.iter(func: MutableIterator<T>.(T) -> Unit) { | |
| val iter = iterator() | |
| while (iter.hasNext()) { | |
| val item = iter.next() | |
| func(iter, item) | |
| } | |
| } | |
| fun example() { | |
| val list = mutableListOf("one", "two", "three", "four") | |
| list.iter { | |
| println(it) | |
| if (it == "three") { | |
| remove() | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment