Skip to content

precondition

ShenYj edited this page Apr 30, 2022 · 1 revision

precondition

在看 BulletinBoard 源码的时候看到了这个类似于断言的 api

precondition(condition:Bool,message:String)

func precondition(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)

在使用上, preconditiondebugrelease 下都生效, 而 assert 只有在 debug 环境下生效

Getting Started

Social

Clone this wiki locally