Posts Tagged “Fundamentals”

Guard Clauses vs. Nested Conditionals

Guard Rail

TLDR; a guard clause is a premature return (early exit) that “guards” against the rest of your code from executing if it’s not necessary (based on criteria you specify).

Soon after I started my career as a Ruby on Rails developer I learned about guard clauses and how they can improve code readability.

Read More

How to create a global .gitignore file

Add a global .gitignore

  1. Open the Terminal
  2. Run touch ~/.gitignore_global to create a global .gitignore file in the home directory
  3. Run open ~/.gitignore_global
  4. Add .vscode/ and any other files or directories that you want to ignore and not include in project-specific .gitignore files (don’t forget to save!)
  5. Run git config --global core.excludesfile ~/.gitignore_global

That’s it! Using .gitignore_global will let you customize your editor without having to edit and commit changes to the .gitignore file for every single project.

Read More

Ruby If, Unless, While and Until

Decisions, decisions

Ruby offers conventional control structures that are found in most common programming languages like if, else and while, however, Ruby also provides less common options like until and unless. These control structures may seem weird at first (“who talks like that?”), but they have their advantages.

Read More