"if" expression question

Posted by Here on Stack Overflow See other posts from Stack Overflow or by Here
Published on 2010-06-09T21:40:56Z Indexed on 2010/06/13 20:32 UTC
Read the original article Hit count: 102

Filed under:

Hi,

I test some simple F# code for "if" expression, but the result is unexpected for me:

> let test c a b = if c then a else b;;
val test : bool -> 'a -> 'a -> 'a

However

> test true (printfn "a") (printfn "b");;
a
b
val it : unit = ()

I'd expect only "a" is printed out but here I got both "a" and "b". I wonder why it comes out this way? Thanks!

© Stack Overflow or respective owner

Related posts about F#