Theory:
Here's a priority table for Ruby.
This table is not visible, but a call to the Ruby method without parentheses has a lower priority than ||and =, but higher than or. See question .
So, for your code, from highest to lowest priority:
Expression with or
foo = 42 or raise "Something went wrong with foo"
=:
( foo = 42 ) or raise "Something went wrong with foo"
raise:
( foo = 42 ) or ( raise "Something went wrong with foo" )
or:
( ( foo = 42 ) or ( raise "Something went wrong with foo" ) )
||
foo = 42 || raise "Something went wrong with foo"
||:
foo = ( 42 || raise ) "Something went wrong with foo"
!
:
foo = 42 || (raise "Something went wrong with foo")
foo = 42 || raise("Something went wrong with foo")
foo = 42 || raise
!
, puts p !
:
p [1,2,3].map do |i|
i*2
end
:
#<Enumerator: [1, 2, 3]:map>
, , :
[2, 4, 6]