"+"在Kotlin协程中? [英] "+" in Kotlin Coroutines?

查看:132
本文介绍了"+"在Kotlin协程中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是

我对表达式coroutineContext + job中的+感到困惑?

I am confused about + in the expression coroutineContext + job?

它在做什么?是操作员覆盖吗?

What it is doing? Is it operator overwriting?

推荐答案

这是运算符超载. 下面显示了方法CoroutineContext::plus的文档:

It’s an example of operator overloading. The following shows the documentation of method CoroutineContext::plus:

open operator fun plus(context: CoroutineContext): CoroutineContext

返回一个上下文,该上下文包含此上下文中的元素和其他上下文中的元素.该上下文中与其他元素具有相同键的元素将被删除.

Returns a context containing elements from this context and elements from other context. The elements from this context with the same key as in the other one are dropped.

它基本上是两个上下文的合并.

It’s basically a merge of two contexts.

这篇关于"+"在Kotlin协程中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆