vaskir
05/21/2017, 6:17 PMkirillrakhman
05/22/2017, 7:12 AMprincekweks
05/22/2017, 8:43 AMxantier
05/22/2017, 8:45 AMfaraxraxeed
05/22/2017, 8:47 AMmg6maciej
05/22/2017, 1:07 PMpackage `in`.xyz
igoticecream
05/22/2017, 5:19 PMikon
05/22/2017, 7:07 PMDmitry Kandalov
05/22/2017, 11:12 PMkevinherron
05/23/2017, 2:49 AMssp
05/23/2017, 3:52 AMkiku
05/23/2017, 1:35 PMvlastachu
05/23/2017, 1:48 PMfun <A, B> ((A)->B).optionalApply(optional: A?): B? {
return optional?.let(this) // "let" good for 1 arg
}
// test
fun testfun1(i: Int) = i + 1
testfun1.optionalApply(null) // "Function invocation expected" on "testfun1"
diesieben07
05/23/2017, 8:48 PMyperess
05/23/2017, 10:03 PMmikehearn
05/23/2017, 10:59 PMgjesse
05/24/2017, 1:49 AMbrett.wooldridge
05/24/2017, 6:24 AMin
operator would be consistently interpreted as containsKey(..)
. The fact that it does not cost me over an hour of debugging, and I think is a surprising result for users. I would expect to be able to switch a collection between HashMap
, ConcurrentHashMap
, ... any Map
and have the code behave consistently.kevin_abrioux
05/24/2017, 8:58 AMserandel
05/24/2017, 11:54 AMmaciekjanusz
05/24/2017, 12:21 PMpoohbar
05/24/2017, 12:22 PMval nejkulaťoulinkatějšíKolečko = Circle(5f, 5f, 10f)
brandon
05/24/2017, 4:17 PMrook
05/24/2017, 5:08 PMremote.foo != null && remote.foo != local.foo
I’m trying to simplify it to something like remote.foo != local.foo ?: false
but it seems like the elvis operator can’t be used that waywjur
05/24/2017, 6:47 PMdeinspanjer
05/24/2017, 7:41 PMprintln("getMember($name)")
when (name) {
"toString" -> return { obj.toString() }
"valueOf" -> return {
when (obj) {
is JsonNull -> null
is JsonArray -> obj.toString()
is JsonPrimitive ->
if (obj.isNumber) obj.asNumber
else if (obj.isBoolean) obj.asBoolean
else obj.asString
else -> obj.toString()
}
}
else -> {
try {
return obj[name!!]
} catch (e: NoSuchElementException) {
return null
}
}
}
mg6maciej
05/24/2017, 9:18 PMval p = item.p
if (p != null) {
} else {
executeSomething()
}
mg6maciej
05/24/2017, 9:26 PMval
before if
like in my original solution, you will get smart casting.amiracam
05/25/2017, 10:59 AMwjur
05/25/2017, 1:16 PMwjur
05/25/2017, 1:16 PMdiesieben07
05/25/2017, 1:25 PMKProperty
, not a KFunction
.wjur
05/25/2017, 1:32 PMJsonProperty
annotation has a required
property, which defaults to false
.diesieben07
05/25/2017, 1:35 PMwjur
05/25/2017, 1:36 PMisMarkedNullable
that defines whether the property is required or not.data class Model(
@JsonProperty("name")
val name: String
)
diesieben07
05/25/2017, 1:39 PMwjur
05/25/2017, 1:40 PMdiesieben07
05/25/2017, 1:42 PMproperty.getter.javaMethod == yourMethod
wjur
05/25/2017, 1:44 PM