Ruby Tricks

## AVERAGE OF ARRAY a = [1,0,2,.,.,.,n] a.instance_eval { reduce(:+) / size.to_f } # HOW TO REMOVE NULL VALUES FROM ARRAY arr = [‘foo’, 0, nil, ‘bar’, 7, ‘baz’, nil] arr.compact arr.compact! arr #=> [‘foo’, 0, ‘bar’, 7, ‘baz’]

RVM Installation

# HOW TO SEE THE CURRENT RUBY VERSION ruby -v # HOW TO INSTALL RVM STABLE VERSION \curl -sSL https://get.rvm.io | bash -s stable –ruby source ~/.rvm/scripts/rvm # HOW TO INSTALL REQUIRE ELEMENTS rvm requirements # HOW TO LIST VERSION KNOWN rvm list known # HOW TO INSTALL RUBY rvm install ruby # HOW TO…