1. 11
  1.  

  2. 17

    Another fun feature of ruby is the __END__ keyword. If that keyword appears alone on a line, ruby will stop parsing the file at that line. In the same file you can use the magic DATA variable to read the rest of the file. Eg:

    #!/usr/bin/env ruby
    puts DATA.read
    __END__
    Hello
    

    This program will output Hello\n when executed.

    This allows to easily create self-unpacking scripts for example, or to join data with code.

    1. 6

      This feature is present in Perl too.

      1. 3

        Perl’s documentation of its __END__ and __DATA__ special literals: https://perldoc.perl.org/perldata.html#Special-Literals

    2. 2

      Very similar article that seems to be easier to understand and read than this one.

      1. 1

        that’s your opinion.. What you say is very subjective..