Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/ruby
    
    ...
       yield 2
    end
    test {|a| puts "You are in the block #{a}"}
    
  2. 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
    
  3. or download this
    sub test {
      say "You are in the method";
    ...
    
    
    test b{ say "You are in the block $_[0]" };
    
  4. or download this
    use strict;
    use warnings;
    ...
    
    
    test b{ say "You are in the block $_[0]" };
    
  5. 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