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
@Deprecated( | |
message = “Tell me what Foo is!”, | |
replaceWith = ReplaceWith(“newHotness(foo, bar)”) | |
) | |
fun oldAndBusted(bar: String) {} |
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
@Deprecated( | |
message = “I forgot about Foo!”, | |
replaceWith = ReplaceWith(“newHotness(DEFAULT, bar)”, “acme.sandbox.foo.DEFAULT”) | |
) | |
fun oldAndBusted(bar: String) {} |
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
@Deprecated( | |
message = “I wrote this backwards”, | |
replaceWith = ReplaceWith(“newHotness(foo, bar)”) | |
) | |
fun oldAndBusted(bar: String, foo: String) {} |
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
@Deprecated( | |
message = “Use something different”, | |
replaceWith = ReplaceWith(“newHotness()”) | |
) | |
fun oldAndBusted() {} |
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
import io.reactivex.Observable | |
import io.reactivex.functions.Consumer | |
class Foo { | |
fun main() { | |
Observable.just("foo").subscribe(this::stringConsumer, this::errorConsumer) | |
} | |
fun stringConsumer(value: String) { TODO() } | |
fun errorConsumer(error: Throwable) { TODO() } |
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
import io.reactivex.Observable | |
import io.reactivex.functions.Consumer | |
class MyErrorHandler : Consumer<Throwable> { | |
override fun accept(t: Throwable?) { TODO() } | |
} | |
class Foo { | |
fun main() { | |
val errorHandler = MyErrorHandler() |
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
interface KotlinConsumer<T> { | |
fun accept(value: T) | |
} | |
class KotlinObservable<T> { | |
fun subscribe(onNext: KotlinConsumer<T>) {} | |
} | |
class Test { | |
fun main() { | |
// FAILS: Type Mismatch: inferred type is KFunction1<@ParameterName String, Unit> but KotlinConsumer<String> was expected |
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
import io.reactivex.Observable | |
import io.reactivex.functions.Consumer | |
class Foo { | |
fun main() { | |
Observable.just("foo", "bar").subscribe(this::stringConsumer) | |
} | |
fun stringConsumer(value: String) { | |
println(value) |
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
fun setOnClickListener(listener: (view: View) -> Unit) { | |
// ... | |
} | |
fun main() { | |
setOnClickListener { it.bringToFront() } | |
setOnClickListener(this::test) | |
} | |
fun test(view: View) { |
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
fun setOnClickListener(listener: (view: View) -> Unit) { | |
// ... | |
} |