#that is not operator:
ar = ["aku", "ganteng", "sekali "]
p ar.map(&:reverse) #["uka", "gnetnag", " ilakes"]
#is roughly equivalent to:
p ar.map { |element| element.reverse } #result ["uka", "gnetnag", " ilakes"]
What is the functionality of &: operator in Ruby?
July 20, 2016
#that is not operator:
ar = ["aku", "ganteng", "sekali "]
p ar.map(&:reverse) #["uka", "gnetnag", " ilakes"]
#is roughly equivalent to:
p ar.map { |element| element.reverse } #result ["uka", "gnetnag", " ilakes"]