Posts From Category: Ruby

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

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