ReturnIf()
함수, 작성 분류
Guard clause: if (cond) { return value; }, the explicit early return that reads as "return value if cond".
import { ReturnIf } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
const ReturnIf: (cond: ReadonlyNode<"bool">, value?: ReadonlyNode) => void매개변수
condReadonlyNode<'bool'>the guard condition.
value선택 사항ReadonlyNodethe value to return; omit it for a bare
return;.
반환값
void
설명
Guard clause: if (cond) { return value; }, the explicit early return that reads as
“return value if cond”. It emits the same statements as If(cond, () => Return(value)).
A native return inside an If body emits nothing, so an early return from a branch is
written in one of these two forms.
예제
예제
ReturnIf(winding.ne(0), f32(1).sub(min_dist))Return(f32(1).add(min_dist))관련 가이드
소스
src/core/ir/builder.ts, 1721행, 커밋 c66579bf 기준