How do you initialize variables in Ruby?

Viewed 13922

Are there any differences between the following ways of initialization of variables?

@var ||= []
@var = [] if @var.nil?
@var = @var || []

Please share your way initializing a variable and state the pros & cons.

2 Answers
Related