The following code results in an error
Example 1
if params[:id] == '2' || params.has_key? :id abort('params id = 2 or nothing') end syntax error, unexpected tSYMBEG, expecting keyword_then or ';' or '\n' if params[:id] == '2' || params.has_key? :id However, switching the conditional statements || adding parentheses works 100%.
Example 2
if params.has_key? :id || params[:id] == '2' abort('params id = 2 or nothing') end Example 3
if (params[:id] == '2') || (params.has_key? :id) abort('params id = 2 or nothing') end Can anyone explain to me why Example 1 will result in an error ?
Thanks