Well, my question is not very clear, but what I want to do is the following:
average = [1, 2, 3].inject(0) { |sum, el| sum + el } / this.size
The code above won't work because of the ridiculous call to this, But what I want to accomplish is to get a reference to the array to which I'm calling inject on. (in this case [1, 2, 3]), Given my ignorance in ruby I did it with this. But, Could you please tell me how to do it right? Is it possible at all to do it without a variable reference?
Thanks in advance!