Ruby Methods and map
A method starts with def and ends with end. The value of its last expression is returned automatically, so return is optional. Ruby does not infer a float from integer division, so the example calls to_f on the size to keep the fraction.
Ruby
def average(values)
values.sum / values.size.to_f
end
puts average([82, 91, 76, 95])
puts [1, 2, 3].map { |n| n * n }.inspect