How is Julia parsing `<condition> ? return <value1> : return <value2>`?

Syntax #1 is preferred (assuming this is a simplified example — otherwise indeed @uniment’s is best!). Syntax #3 is parsed as

a==1 ? return (true : return false)

i.e., with : as a range, which is then a syntax error because the ternary operator ? doesn’t have its other half (:).

1 Like