Skip to content

Instantly share code, notes, and snippets.

@mdaftab88
Last active May 7, 2021 13:41
Show Gist options
  • Save mdaftab88/dcbd8318138af1f1d964ac3913ef907a to your computer and use it in GitHub Desktop.
Save mdaftab88/dcbd8318138af1f1d964ac3913ef907a to your computer and use it in GitHub Desktop.
Today I Learned....

TIL - Today I Learned

Sunday, 25 April 2021

Rails Polymorphic Associations

Sunday, 02 May 2021

  1. How to give a line break in a markdown file
    Just add two spaces at the end of the line. It worked for me. :)
  2. 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 for BEGIN statements, and executes the code in their bodies. Then it goes back to line 1 and starts executing sequentially.
  3. 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

Questions To Be Answered.

  1. What is ruby __END__ token?
  2. What is ruby END keyword?
  3. What are shutdown methods in ruby?
  4. What is at_exit in ruby?

Common Questions

  1. 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.
  2. What is ruby __END__ token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment