Ampersand
The ampersand symbol (&
) is used in several syntactically distinct ways in Ruby. You are probably looking for one of the following:
- Safe Navigation Operator:
book&.author&.name
- Block argument:
def method(&block)
- Block Conversion Operator:
arr.map(&:upcase)
- "And Equals" Conditional assignment:
variable &&= value
- Bitwise AND operator:
10 & 3 #=> 2