In this example from a blog post,
class Array
def each
i = 0
while(i < self.length) do
yield(self[i])
i += 1
end
end
end
my_array = ["a", "b", "c"]
my_array.each {|letter| puts letter }
# => "a"
# => "b"
# => "c"
Is it necessary to use self
in the statement:
yield(self[i])
Or would it be ok to simply say:
yield i