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
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