zjuhasz
02/03/2019, 5:27 AMopen class D { }
class D1 : D() { }
open class C {
open fun D.foo() {
println("D.foo in C")
}
open fun D1.foo() {
println("D1.foo in C")
}
fun caller(d: D) {
d.foo() // call the extension function
}
}
class C1 : C() {
override fun D.foo() {
// Is there some way to get something like super.foo() on this receiver?
println("D.foo in C1")
}
override fun D1.foo() {
println("D1.foo in C1")
}
}
fun main() {
C().caller(D()) // prints "D.foo in C"
C1().caller(D()) // prints "D.foo in C1" - dispatch receiver is resolved virtually
C().caller(D1()) // prints "D.foo in C" - extension receiver is resolved statically
}
tipsy
02/03/2019, 12:37 PMassertThat(validate("true").asBoolean().getOrThrow(), `is`(instanceOf(Boolean::class.java))) // old - hamcrest
assertThat(validate("true").asBoolean().getOrThrow()).isInstanceOf(Boolean::class.java) // new - assertj
outputs:
Expecting:
<true>
to be an instance of:
<boolean>
but was instance of:
<java.lang.Boolean>
does anyone know why?Davide Giuseppe Farella
02/03/2019, 8:54 PMinfix function
that returns a KFunction1
basically for call an infix function with 2 params ( 1 param + a lamba ).
Example:
( root child "node" ) {
it attr "child node 1"
it childValue "child node 2"
it childValue "child node 3"
}
Davide Giuseppe Farella
02/03/2019, 8:55 PMhardness
04/29/2019, 6:45 AMpoohbar
04/29/2019, 2:04 PMlazy
properties thread-safe?Dangelomjoyce
04/29/2019, 10:11 PMTrevor
04/29/2019, 11:44 PMLawik
04/30/2019, 11:01 AMWarning:kotlin: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
.../.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.2.31/95d6a67e8787280a82a2059e54e4db7ac6cfe74/kotlin-stdlib-jdk7-1.2.31.jar (version 1.2)
.../.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.2.31/50094b02ec8a4c2e4444073c722bb56c8a52b83c/kotlin-stdlib-jdk8-1.2.31.jar (version 1.2)
.../.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.3.10/dd02865be0351707554b16a896b766b2396cdafa/kotlin-reflect-1.3.10.jar (version 1.3)
.../.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.30/9ea98e65c246d34de9af59c104ad9bdea4908ee/kotlin-stdlib-1.3.30.jar (version 1.3)
.../.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.30/989a125fdb6e4d0d75a016032e03e1e3b57a13d/kotlin-stdlib-common-1.3.30.jar (version 1.3)h
warning? The 1.2 stdlib dependencies seem to come from a library I have added as a dependency to my project?
EDIT: Nevermind, I had to add kotlin-stdlib-jdk7:1.3.21
and kotlin-stdlib-jdk8:1.3.21
dependencies explicitly to fix it.Bernhard
04/30/2019, 11:45 AMalex.hart
04/30/2019, 2:03 PMalex.hart
04/30/2019, 2:04 PMTmpod
04/30/2019, 2:25 PMkarelpeeters
04/30/2019, 2:47 PMthis
isn't a T
, so why should that work?jcogilvie
04/30/2019, 9:22 PMDelegates.observable
that's approximately equivalent to lateinit? right now I have two options:
var foo: Foo? = null
set(value) {
field = value
update()
}
var foo2: Foo? by Delegates.observable(null as Foo?) {
prop, old, new -> update()
}
what would be cleaner is a version of Delegates.observable
that didn't require an initial value, since my property is semantically not nullable... only late.Kirill Zhukov
05/01/2019, 7:59 PMimport com.google.common.truth.Subject
import kotlin.contracts.contract
inline fun <reified T> Subject<*, *>.isInstanceOf() {
contract {
returns() implies (this@isInstanceOf is T)
}
isInstanceOf(T::class.java)
}
Kirill Zhukov
05/01/2019, 8:00 PMKirill Zhukov
05/01/2019, 8:00 PMtrevjones
05/01/2019, 10:03 PMHullaballoonatic
05/02/2019, 4:42 AMcompareTo
operatorGeert
05/02/2019, 8:26 AM// No actual instantiation of class 'Password' happens
// At runtime 'securePassword' contains just 'String'
val securePassword = Password("Don't try this in production")
And the Identifier: inline class Identifier(val value: String)
karelpeeters
05/02/2019, 8:28 AMGeert
05/02/2019, 8:30 AMHullaballoonatic
05/02/2019, 7:23 PMsubList
but takes an initial index and numValues following? i.e.:
fun <T> List.subVector(i: Int, length: Int): List<T> = subList(i, i + length)
iex
05/02/2019, 10:40 PMval
(file scoped) and import it everywhere?iex
05/02/2019, 10:41 PMval log: Log = MyLogImpl()
in a file and be able to call log.d("...")
everywhereiex
05/02/2019, 10:45 PMiex
05/02/2019, 10:45 PMval
works. Ignore mebjonnh
05/03/2019, 9:10 PMbjonnh
05/03/2019, 9:10 PM