eygraber
03/16/2017, 4:50 PMfun <T: Any?> T?.or(other: T): T {
return if(this == null) {
other
}
else {
this
}
}
gjesse
03/16/2017, 4:52 PMfun <T: Any?> T?.or(other: T) = this ?: other
gjesse
03/16/2017, 4:53 PMorDefault(..)
because or
implies some boolean logicmg6maciej
03/16/2017, 4:54 PM?
in <T : Any>
.eygraber
03/16/2017, 4:58 PM<T : Any>
and <T : Any?>
mg6maciej
03/16/2017, 5:06 PMT
as Any?
, you allow it to be null, so argument to your function can be null.mg6maciej
03/16/2017, 5:07 PM?
in T?.or
redundant.mg6maciej
03/16/2017, 5:08 PMfun <T: Any> T?.or(other: T) = this ?: other
it will not accept null as argument, but it will as receiver.eygraber
03/16/2017, 8:42 PMor
on non-nullable objects.stepango
03/23/2017, 10:42 AM?:
?