I am very new to ruby and still in learning phase. I recently came across statements like .inject(:+)
and a.select(&:even?)
. I do not know what :+
or &:
does exactly.
Can someone please help me understand what it is?
Also, are there any other similar operators present in ruby, if yes, can you please point me to a reference where I can learn more about these operators.
I have googled about these operators but I could not find a solid document or resource which talks specifically about these kind of operators and hence, I am here seeking the community's help.
=> [1,2,3,4,5].inject(:+)
=> 15
=> [1,2,3,4,5].select(&:even?)
=> [2,4]