mathew murphy
07/30/2019, 2:50 PMMarcelus Trojahn
07/30/2019, 3:38 PMstandinga
07/30/2019, 4:04 PMwhen (i) {
in 0..10 -> //
in 10..20 -> //
}
Gunslingor
07/30/2019, 6:25 PMGunslingor
07/30/2019, 6:49 PMNezteb
07/31/2019, 4:27 PMval csvLines = generateSequence { csv.readMap() }.toList()
Nezteb
07/31/2019, 5:59 PMdata class
but I don’t think I can apply annotations to those fields.Nick Halase
07/31/2019, 6:21 PMiammini5
07/31/2019, 9:26 PMadolev
08/01/2019, 12:44 PMNezteb
08/01/2019, 8:12 PMreik.schatz
08/02/2019, 8:07 AMval number = Math.max(x, x + y)
arekolek
08/02/2019, 11:41 AMsealed class Item {
data class Foo(val id: Int) : Item()
object Bar : Item()
}
fun List<Item>.trim() = dropLastWhile { it is Item.Bar || it.id == IGNORED_ID }
It works if I do it !is Item.Foo || it.id == IGNORED_ID
though, which is understandableross_a
08/02/2019, 1:00 PMkotlin.Number
is an abstract class, rather than an interface?bbaldino
08/02/2019, 3:35 PMMarcelus Trojahn
08/03/2019, 12:27 AMIaroslav Postovalov
08/03/2019, 9:08 AMpublic lateinit var command: CommandScope
internal set
Viktor Qvarfordt
08/03/2019, 12:20 PMinline class
but it does not provide init
so I have nowhere to place an assert
. Any ideas?bod
08/03/2019, 3:10 PMPair<Date>
for it. This way from Kotlin it's nice, you can do foobar(dateFrom to dateTo)
. But from Java you're going to have to do foobar(new kotlin.Pair<>(dateFrom, dateTo))
and now you need Kotlin in your dependencies for this to work - not cool. Ideally I'd like to have both to
and not this Java issue... Ideas?Big Chungus
08/03/2019, 4:34 PMbarteks2x
08/03/2019, 7:55 PMgroostav
08/03/2019, 11:52 PMList<List<T>>
which can be conceptualized as a "list of columns", (where each inner List<T>
is a column), whats the most elegant collection method to use to get a list of rows?wuseal
08/04/2019, 9:00 AMRobert Jaros
08/04/2019, 10:41 AMAny
) is a function/lambda? v is Function<*>
works on JVM, but doesn't work on JS platformStefan
08/04/2019, 10:59 AMIfvwm
08/04/2019, 11:29 AMIfvwm
08/05/2019, 3:40 AMSergio Pro
08/05/2019, 7:46 AMval longs = List(100) { random.nextLong(6868L) }
assertThat(longs.all { it < 6869L }).isTrue()
But when I use property access syntax for isTrue
it throws Cannot infer type parameter SELF in val <SELF : AbstractBooleanAssert<SELF!>!> AbstractBooleanAssert<SELF>.isTrue: SELF!
val longs = List(100) { random.nextLong(6868L) }
assertThat(longs.all { it < 6869L }).isTrue
I'm using assertJ. Just wondering if this is kotlin or assertj issue.Kirill Rozov
08/05/2019, 8:06 AMMaksim Vlasov
08/05/2019, 10:21 AMMaksim Vlasov
08/05/2019, 10:21 AMgildor
08/05/2019, 10:22 AMMaksim Vlasov
08/05/2019, 10:26 AMspand
08/05/2019, 10:29 AMgildor
08/05/2019, 10:32 AMMaksim Vlasov
08/05/2019, 10:33 AMgildor
08/05/2019, 10:33 AMMaksim Vlasov
08/05/2019, 10:33 AMBig Chungus
08/05/2019, 10:36 AMisLocked
property uppon setter invocation which is false by default and throw an exception if it's true. finally have a lock() method in your entity to set it to true when you;re done mutating.Maksim Vlasov
08/05/2019, 10:39 AMBig Chungus
08/05/2019, 10:50 AMabstract class LockableEntity(isLocked: Boolean = false) {
private var isLocked = false
fun lock() {
isLocked = true
}
protected class LockableProperty<T>(initialValue: T) {
private var value: T = initialValue
operator fun getValue(thisRef: LockableEntity, prop: KProperty<*>): T {
return value
}
operator fun setValue(thisRef: LockableEntity, prop: KProperty<*>, value: T) {
if (!thisRef.isLocked) {
this.value = value
} else {
throw IllegalStateException("${thisRef::class.simpleName} is locked! Further property modification is forbidden")
}
}
}
}
class SomeHibernateEntity() : LockableEntity() {
var x: String by LockableProperty("Initial")
}
fun main() {
val tmp = SomeHibernateEntity()
tmp.x = "modified"
tmp.lock()
tmp.x = "Shouldn't succeed"
}
Maksim Vlasov
08/05/2019, 10:59 AMgildor
08/05/2019, 10:59 AMBig Chungus
08/05/2019, 11:08 AMval x:Any = ???
import kotlin.reflect.*
abstract class LockableEntity(private var isLocked: Boolean = false) {
fun lock() {
isLocked = true
}
protected class LockableProperty<T>(initialValue: T) {
private var value: T = initialValue
operator fun getValue(thisRef: LockableEntity, prop: KProperty<*>): T {
return value
}
operator fun setValue(thisRef: LockableEntity, prop: KProperty<*>, value: T) {
if (!thisRef.isLocked) {
this.value = value
} else {
throw IllegalStateException("${thisRef::class.simpleName} is locked! Further property modification is forbidden")
}
}
}
}
class SomeHibernateEntity(x: String, y: Int, val immutable: Int) : LockableEntity() {
var x by LockableProperty<String>(x)
var y: Int by LockableProperty(y)
}
fun main() {
val tmp = SomeHibernateEntity("1", 2, 3)
tmp.x = "1 modified"
tmp.lock()
tmp.x = "Shouldn't succeed"
}
interface ILockableEntity {
fun isLocked(): Boolean
fun lock()
class LockableProperty<T>(initialValue: T) {
private var value: T = initialValue
operator fun getValue(thisRef: ILockableEntity, prop: KProperty<*>): T {
return value
}
operator fun setValue(thisRef: ILockableEntity, prop: KProperty<*>, value: T) {
if (!thisRef.isLocked()) {
this.value = value
} else {
throw IllegalStateException("${thisRef::class.simpleName} is locked! Further property modification is forbidden")
}
}
}
}
class SomeHibernateEntity(x: String, y: Int, val immutable: Int) : ILockableEntity {
private var locked = false
override fun isLocked() = locked
override fun lock() {
locked = true
}
var x by ILockableEntity.LockableProperty(x)
var y: Int by ILockableEntity.LockableProperty(y)
}
fun main() {
val tmp = SomeHibernateEntity("1", 2, 3)
tmp.x = "1 modified"
tmp.lock()
tmp.x = "Shouldn't succeed"
}
interface ILockableEntity {
val isLocked:Boolean
fun lock()
class LockableProperty<T>(initialValue: T) {
private var value: T = initialValue
operator fun getValue(thisRef: ILockableEntity, prop: KProperty<*>): T {
return value
}
operator fun setValue(thisRef: ILockableEntity, prop: KProperty<*>, value: T) {
if (!thisRef.isLocked) {
this.value = value
} else {
throw IllegalStateException("${thisRef::class.simpleName} is locked! Further property modification is forbidden")
}
}
}
}
class SomeHibernateEntity(x: String, y: Int, val immutable: Int) : ILockableEntity {
override val isLocked: Boolean
get() = locked
private var locked = false
override fun lock() {
locked = true
}
var x by ILockableEntity.LockableProperty(x)
var y: Int by ILockableEntity.LockableProperty(y)
}
fun main() {
val tmp = SomeHibernateEntity("1", 2, 3)
tmp.x = "1 modified"
tmp.lock()
tmp.x = "Shouldn't succeed"
}
streetsofboston
08/05/2019, 12:19 PMoverride var
on a val
)karelpeeters
08/05/2019, 2:27 PMlistOf
does.gildor
08/05/2019, 2:54 PMDico
08/05/2019, 5:14 PMBig Chungus
08/05/2019, 6:31 PMMaksim Vlasov
08/06/2019, 11:23 AMgildor
08/07/2019, 1:58 AMcopy
way.