我想知道ARCore
/ Kotlin
中是否有类似的语义结构,例如guard let
/ ARKit
中的以下Swift
语句?>
let anchor: ARAnchor?
guard let planeAnchor = anchor as? ARPlaneAnchor else {
print("condition not met")
return
}
答案 0 :(得分:1)
我认为我已经找到 Elvis运算符和安全类型转换运算符的ARCore planeAnchor
的必需语义:
public class CenterPosePlaneAnchor { ... }
val anchor: Anchor?
val info = "condition not met"
val planeAnchor = anchor as? CenterPosePlaneAnchor ?: return println(info)