# Built-in functions [ ](https://gezf7g7pd5.execute-api.ap-northeast-1.amazonaws.com/default/source_up_to_date?owner=erg-lang&repos=erg&ref=main&path=doc/EN/syntax/05_buildtin_funcs.md&commit_hash=6dc8c5015b6120497a26d80eaef65d23eb2bee2a) ## if `if` is a function that changes processing depending on a condition. ```erg result: Option Int = if! Bool.sample!(), do: log "True was chosen" 1 print! result # None (or 1) ``` `.sample!()` returns a random set of values. If the return value is true, `print! "True"` is executed. You can also specify what to do if the condition is false; the second do block is called the else block. ```erg result: Nat = if Bool.sample!(): do: log "True was chosen" 1 do: log "False was chosen" 0 print! result # 1 (or 0) ``` If the process is a single line, you can omit indentation. ```erg result = if Bool.sample!(): do 1 do 0 ``` ## for You can use `for` to write a repeating process. ```erg match_s(ss: Iterator(Str), pat: Pattern): Option Str = for ss, s -> if pat.match(s).is_some(): break s ```