In Kotlin String.toInt() and Char.toInt() do very different things.
>>> "9".toInt()
9
>>> '9'.toInt()
57
>>>
In Kotlin String.toInt() and Char.toInt() do very different things.
>>> "9".toInt()
9
>>> '9'.toInt()
57
>>>
| fun TestContext<*>.withTestTiming() { | |
| var start: Long? = null | |
| before { | |
| start = System.currentTimeMillis() | |
| } | |
| after { | |
| start?.let { | |
| val timeTaken = System.currentTimeMillis() - it |
| class Fixture { | |
| val tempFile: File | |
| } | |
| fixture { testDescriptor -> | |
| Fixture(System.createTempFile(testDescriptor.fullName.joinToString("/"), ".json")) | |
| } | |
| test { | |
| doSomethingThatWritesTo(tempFile) |
E.g. the stdlib defines the following function:
fun CharSequence?.isNullOrBlank(): BooleanYou can take a reference to this extension function like this:
val isNullOrBlankFn = CharSequence?::isNullOrBlank| package browser | |
| import org.w3c.dom.events.Event | |
| import org.w3c.dom.events.EventTarget | |
| typealias EventHandler<E> = (E) -> Unit | |
| external val speechSynthesis: SpeechSynthesis | |
| external class SpeechSynthesis : EventTarget { |
| package browser | |
| import org.w3c.dom.Element | |
| import org.w3c.dom.events.UIEvent | |
| typealias TouchId = Int | |
| external interface Touch { | |
| val identifier: TouchId | |
| val target: Element |
override fun close() = client?.disconnect()
Return type of 'close' is not a subtype of the return type of the overridden member 'public abstract fun close(): Unit defined in java.lang.AutoCloseable'
Unit? is a supertype of Unit, not a subtype.
Some libraries define optional interfaces that have to be discovered by dynamic type checking and can only used after casting to the optional interface type.
For example, a "ScriptEngine" provided by the Java scripting API only provides methods for evaluating scripts.
val js : ScriptEngine = ScriptEngineManager().getEngineByName("nashorn")
js.eval("print('hello, world');")
But the "nashorn" script engine is specified to also implement the Invocable interface, that allows the host program to invoke functions defined by a script, and the Compilable interface, that allows the host program to compile a script and then execute the compiled form.
| MARKDOWN_SRC:=$(shell find doc -name '*.md') | |
| DIAGRAM_SRC:=$(shell find doc -name '*.plantuml') | |
| MARKDOWN_FORMAT=markdown+fenced_code_blocks+fenced_code_attributes+grid_tables+footnotes | |
| # Order is significant when multiple CSS files | |
| CSS_SRC:=styles/style.css | |
| SITE_HTML=$(MARKDOWN_SRC:doc/%.md=out/site/%.html) $(DIAGRAM_SRC:doc/%.plantuml=out/site/%.png) | |
| SITE_CSS=$(CSS_SRC:styles/%=out/site/%) |
| val <T> T.` `: T get() = this | |
| val <T> T.` `: T get() = this | |
| val <T> T.` `: T get() = this | |
| val <T> T.` `: T get() = this | |
| val <T> T.` `: T get() = this | |
| val <T> T.` `: T get() = this | |
| val <T> T.` `: T get() = this | |
| val <T> T.` `: T get() = this | |
| val <T> T.` `: T get() = this | |
| val <T> T.` `: T get() = this |