Points learned!

Good points learned during the course of time.

Lesson 1 (Ruby Fundamentals)

  • The symbol form of operators &&, || have higher precedence than assignment operator = while the assignment operator = has higher precedence than or, and, not.
  • The reflective method local_variables of module Kernel lists the local variables in that context as an array of strings.
  • arg1 || arg2 returns arg1 unless arg1 is false. A common idiom is to use || to assign a value to a variable only if that variable isn’t already set  – @variable = @variable || “default value”
  • In Ruby, everything is true except the reserved words false and nil.

Lesson-2(Ruby Methods):

  • The statement arg1=”x”, arg2=”y”, arg3=”z” is equivalent to arg1 = [x, arg2="y", arg3="z"].
  • Variable have higher precedence than methods. When there’s a “name-clash” Ruby uses first the variable. One can  coerce Ruby to call the method by issuing name().

Lesson-3, 4(Blocks/Files):

  • Blocks are not objects, but they can be converted into objects of class Proc. This can be done by calling the lambda method of the module Kernel.The class Proc has a method call that invokes the block.
  • The expression #{} is evaluated in double quote strings and not in single quote strings.

Lesson-6 (Open Classes):

  • In Ruby, we can always add methods to an existing class. The good practice is to create a subclass of the original class and override parent’s method or add new one.

1 Comment

Filed under Uncategorized

Introduction!

This month(Feburary) marks Ruby’s 15th birthday. Yukihiro “Matz” Matsumoto–creator of Ruby confirmed that Ruby was conceptualized and named on Feb. 24, 1993. Mark your calendars. While this doesn’t yet qualify Ruby as an old-timer among programming languages, it’s a good indication that it’s here to stay and probably doesn’t deserve to be called a newcomer any more.” — Satish Talim

Leave a Comment

Filed under Uncategorized