Created
June 5, 2015 18:58
-
-
Save VladimirReshetnikov/77cc53a119d7755a3e79 to your computer and use it in GitHub Desktop.
This file contains 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
public interface ImmutableCollection<out E>: Collection<E> { | |
fun <B: Builder<in E>, R> invokeOnBuilder(f: (B) -> R) : R | |
public interface Builder<E> { | |
fun add(e: E): Builder<E> | |
fun build(): ImmutableCollection<E> | |
} | |
} | |
fun <E1, E: E1> ImmutableCollection<E>.add(e: E1): ImmutableCollection<E1> { | |
return this.invokeOnBuilder { builder: ImmutableCollection.Builder<E1> -> builder.add(e).build() } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment