arr.each { | x | # iterates the elements, NOT the index puts x }
Basically, each here is just a method that recieves a block (like perl's anonymous subroutines) as an argument. The container type is then responsible for calling the block for each element.
Any class can provide it's own each method - this is not a built-in function like perl's foreach.
In reply to Re^3: Perl is more intuitive
by Joost
in thread Perl is more intuitive
by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |