From 8ee66237b445e81c9c1bae0876c1cb83ea996485 Mon Sep 17 00:00:00 2001 From: murjune Date: Wed, 17 Aug 2022 04:55:37 +0900 Subject: [PATCH] =?UTF-8?q?#178=20[feat]=20safeLet=20=ED=99=95=EC=9E=A5?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/hous/hous_aos/util/SafeLet.kt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 app/src/main/java/com/hous/hous_aos/util/SafeLet.kt diff --git a/app/src/main/java/com/hous/hous_aos/util/SafeLet.kt b/app/src/main/java/com/hous/hous_aos/util/SafeLet.kt new file mode 100644 index 00000000..35569106 --- /dev/null +++ b/app/src/main/java/com/hous/hous_aos/util/SafeLet.kt @@ -0,0 +1,7 @@ +package com.hous.hous_aos.util + +/** + * 변수 2가지 이상 null 체크할 때 사용 */ +inline fun safeLet(p1: T1?, p2: T2?, block: (T1, T2) -> R?): R? { + return if (p1 != null && p2 != null) block(p1, p2) else null +}