I'm new at Ruby and currently learning blocks. As far as I see, there are two ways of calling a parameter to be used inside a block. The firs way is for example:
def function (parameter)
yield(x)
end
so we can call the method by using
function{|x| print x}
My question is about defining a method by following the pattern object.method. For example
parameter.function{|x| #something }
How do you define the block to receive the (1..100) object just like, for example, the each method?:
(1..100).each{|x| print x}