- or download this
#!/usr/bin/ruby
...
yield 2
end
test {|a| puts "You are in the block #{a}"}
- or download this
/usr/bin/ruby -w /home/lanx/perl/ruby/yield.rb
You are in the method
You are in the block 1
You are again back to the method
You are in the block 2
- or download this
sub test {
say "You are in the method";
...
test b{ say "You are in the block $_[0]" };
- or download this
use strict;
use warnings;
...
test b{ say "You are in the block $_[0]" };
- or download this
/usr/bin/perl -w /home/lanx/perl/ruby/yield.pl
You are in the method
You are in the block 1
You are again back to the method
You are in the block 2