TIL - Today I Learned
Rails Polymorphic Associations
- How to give a line break in a markdown file
Just add two spaces at the end of the line. It worked for me. :) BEGIN
in Ruby.
As of today, I was expecting execution for every ruby program starts from the first line of the file. But this is not true all the time. Ruby interpreter first scans the file forBEGIN
statements, and executes the code in their bodies. Then it goes back to line 1 and starts executing sequentially.- What are the ways ruby interpretor stops execution of a ruby program?
- It executes a statement that causes the Ruby program to terminate
- It reaches the end of the file
- It reads a line that marks the logical end of the file with the token
__END__
Ref: The Ruby Programming Language
- What is ruby
__END__
token? - What is ruby
END
keyword? - What are
shutdown methods
in ruby? - What is
at_exit
in ruby?
- Difference between scripting language and compiled language
Compiled languages are the languages that is compiled prior to the execuation whereas scripting languages doesn't need to be compiled before execution. Scripting language uses an interpeter that directly executes statements line by line. Other major difference: Compiled languages normally start execution from a main method but scripting languages always start execution from the first line of the program. - What is ruby
__END__
token