Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    if <expr1> then <expr2.1>;<expr2.2> else <expr3>
Actually, this will not work, I was also confused by it.

    # if true then (); 1 else 2;;
    Error: Parse error: [str_item] or ";;" expected (in [top_phrase])
    # if true then begin (); 1 end else 2;;
    - : int = 1
    # if true then ((); 1) else 2;;
    - : int = 1
The confusion comes from the fact that it doesn't behave the same way in match expressions:

    # match true with | true -> (); 1 | false -> 2;;
    - : int = 1


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: