vararg引数を別のvarags引数に渡す際は spread 演算子が必要

This commit is contained in:
tateisu 2022-06-03 23:23:44 +09:00
parent be659255d8
commit 2273f7f94c
3 changed files with 7 additions and 7 deletions

View File

@ -95,7 +95,7 @@ object DlgConfirm {
}
suspend fun AppCompatActivity.confirm(@StringRes messageId: Int, vararg args: Any?) =
confirm(getString(messageId, args))
confirm(getString(messageId, *args))
suspend fun AppCompatActivity.confirm(message: String) {
suspendCancellableCoroutine<Unit> { cont ->

View File

@ -43,19 +43,19 @@ class LogCategory(category: String) {
private fun msg(priority: Int, res: Resources, @StringRes stringId: Int, args: Array<out Any?>) =
msg(priority, res.getString(stringId, *args))
fun e(res: Resources, @StringRes stringId: Int, vararg args: Any) =
fun e(res: Resources, @StringRes stringId: Int, vararg args: Any?) =
msg(Log.ERROR, res, stringId, args)
fun w(res: Resources, @StringRes stringId: Int, vararg args: Any) =
fun w(res: Resources, @StringRes stringId: Int, vararg args: Any?) =
msg(Log.WARN, res, stringId, args)
fun i(res: Resources, @StringRes stringId: Int, vararg args: Any) =
fun i(res: Resources, @StringRes stringId: Int, vararg args: Any?) =
msg(Log.INFO, res, stringId, args)
fun d(res: Resources, @StringRes stringId: Int, vararg args: Any) =
fun d(res: Resources, @StringRes stringId: Int, vararg args: Any?) =
msg(Log.DEBUG, res, stringId, args)
fun v(res: Resources, @StringRes stringId: Int, vararg args: Any) =
fun v(res: Resources, @StringRes stringId: Int, vararg args: Any?) =
msg(Log.VERBOSE, res, stringId, args)
///////////////////////////////

View File

@ -88,4 +88,4 @@ fun AppCompatActivity.showError(ex: Throwable, caption: String? = null) {
}
fun Context.errorString(@StringRes stringId: Int, vararg args: Any?): Nothing =
error(getString(stringId, args))
error(getString(stringId, *args))