For example
func(@param) do |f|
some code here
end
and
@param.each do |sth|
some code here
end
What does the absolute value sign do here? I don't understand these two pieces of code.
It's the local variable within the block, so for the line:
@param.each do |sth|
you're iterating over @param right, well each item in @param is referred to singularly as sth.
So if @param refers to an array containing the numbers
[1,3,5,4]
During the first iteration sth will be 1, then 3, then 5, then 4.
Same goes for :
func(@param) do |f|
except now the local variable is called f! You could call it anything you want, even |ihavenoideawhatimdoing|
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With