Ruby tutorial session 9

Hi  Readers,

Remember these things while coding in Ruby. Naming convention is important for good programmer, once you wrote the code it should be in systematic way.

Naming Conventions:

  • MyClass
  • method_name, destructive_method!, question_method?, setter_method=
  • MY_CONSTANT = 3.14
  • local_variable = 3.14
  • @instance_variable
  • @@class_variable
  • $global_variable
Just check your previous code in ruby is written in this naming convention format or not. Practice the naming convention coding to better and clean understanding to others also.

Boolean Expressions:

  • All objects evaluate to true except false and nil
  • false and true are the only instances of FalseClass and TrueClass
  • Boolean expressions return the last evaluated object
  • a and b or c <=> (a and b) or c
  • a = b and c <=> (a = b) and c
  • a = b && c <=> a = (b && c)
  • puts a if a = b # Using assignments in boolean expressions
  • a = true; b = false; a and b and c() # => c() is never invoked
 Good to know the details about the boolean expressions, why because in my experience i face lot of issues with boolean expressions, i found that lot of bugs reported in my past projects most of the bugs having the issue with boolean expressions, So get hands on experience on boolean expression.

Thank for reading.

If you like follow this blog.

No comments:

Post a Comment

My Experience in RUBYCONF INDIA 2016

Hi Readers, Rubyconf India is a global event complementing other RubyConf events across the world. I attended this event held on 19-20 ma...