dimsuz
02/02/2017, 12:36 PMif (flag1 && (flag2 || someFlag.orTrue()))
rather than if (flag1 && (flag2 || someFlag ?: true))
, perhaps it's a personal preference 🙂aimozg
02/02/2017, 12:37 PMaimozg
02/02/2017, 12:37 PM?:
in such casesdimsuz
02/02/2017, 12:37 PMdimsuz
02/02/2017, 12:38 PMfalse.orTrue()
wouldn't make sense, because orTrue()
is defined mainly to handle nullable booleans...dimsuz
02/02/2017, 12:38 PMaimozg
02/02/2017, 12:41 PMfun <T:Any> T?.default(value: T)
then?:)aimozg
02/02/2017, 12:41 PMdimsuz
02/02/2017, 1:14 PMList.orEmpty()
, String.orEmpty()
...aimozg
02/02/2017, 1:32 PM?.
-chains but have to augment them a lot to include stuff >=
, x+this
etccedric
02/02/2017, 5:56 PMHashMap.putIf()
? A generalization of putIfAbsent
where the condition can be passed as a closure instead of just being get() == null
?jdiaz
02/02/2017, 6:27 PMcedric
02/02/2017, 6:49 PMHashMap
actually 🙂jdiaz
02/02/2017, 6:51 PMcedric
02/02/2017, 7:15 PMval m = hashMapOf<String, String>()
val f = BiFunction { k: String, v: String? ->
if (v == null) "defaultString" else v + " added string"
}
m.compute("foo", f)
kirillrakhman
02/02/2017, 7:16 PMcedric
02/02/2017, 7:18 PMBiFunction {}
cedric
02/02/2017, 7:18 PMcedric
02/02/2017, 7:18 PMcedric
02/02/2017, 7:19 PMm.compute("foo") { k: String, v: String? ->
if (v == null) "defaultString" else v + " added string"
}
I could have sworn this didn’t used to compilekirillrakhman
02/02/2017, 10:12 PMtreelzebub
02/02/2017, 10:22 PMdamian
02/02/2017, 10:37 PMcedric
02/02/2017, 10:39 PMgildor
02/03/2017, 3:03 AMif (flag1 && (flag2 || someFlag == true))
More clean and native then elvis or extension functionlouiscad
02/04/2017, 12:42 AMjw
02/04/2017, 1:32 AMsreich
02/04/2017, 1:26 PMlouiscad
02/04/2017, 6:12 PMlouiscad
02/04/2017, 6:13 PM