withViewResult

inline fun <T> Fragment.withViewResult(errorMessage: String = "Fragment view is null", block: (View) -> T): T?

Executes the given block and returns a result if the Fragment's view is not null.
Returns null and logs an error if the view is null.

Fragment의 view가 null이 아닌 경우 주어진 블록을 실행하고 결과를 반환합니다.
view가 null이면 null을 반환하고 에러를 로깅합니다.

Return

The result of the block, or null if view was null.

블록의 결과, 또는 view가 null이면 null.

Parameters

T

The type of the result returned by the block.

블록이 반환하는 결과의 타입.

errorMessage

Custom error message to log when view is null.

view가 null일 때 로깅할 커스텀 에러 메시지.

block

The block to execute with the non-null view.

null이 아닌 view로 실행할 블록.