Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin对arrow、lamda、、、的组合使用,让我来。这是什么意思? dto.someMap[MAP_A]?.let(::setAId)可以像_Kotlin - Fatal编程技术网

Kotlin对arrow、lamda、、、的组合使用,让我来。这是什么意思? dto.someMap[MAP_A]?.let(::setAId)可以像

Kotlin对arrow、lamda、、、的组合使用,让我来。这是什么意思? dto.someMap[MAP_A]?.let(::setAId)可以像,kotlin,Kotlin,二,。 是的,没错。你可以这样想 val value = dto.someMap[MAP_A] if (value != null) { setAId(value) } //整个函数将返回OrderProtoBuilders.itItem创建的项 有趣的盈利模式( domainOrderId:String, pIds:List=emptyList() ):Iteem=let{dto-> //returnorderprotobuilders.yteem 订单{ //对该项执行一些额外的初

二,。 是的,没错。你可以这样想

val value = dto.someMap[MAP_A]
if (value != null) {
    setAId(value)
}
//整个函数将返回OrderProtoBuilders.itItem创建的项
有趣的盈利模式(
domainOrderId:String,
pIds:List=emptyList()
):Iteem=let{dto->
//returnorderprotobuilders.yteem
订单{
//对该项执行一些额外的初始化
}
}
?。
表示“仅当左边的对象不为空时”,而
表示“执行此代码”(调用它的对象可通过
),最后
让{dto->…}
设置自定义别名(通过
dto
访问对象)。
let { dto ->
    OrderProtoBuilders.theItem {...
val value = dto.someMap[MAP_A]
if (value != null) {
    setAId(value)
}
//the whole function will return item created by OrderProtoBuilders.theItem
fun theItemDTO.toDomainModel(
    domainOrderId: String,
    pIds: List<Long> = emptyList()
): theItem = let { dto ->
    //return OrderProtoBuilders.theItem
    OrderProtoBuilders.theItem {
        //do some additional initialization of the Item
    }
}