Intern Track Roadmap

Logic: boolean algebra

This course covers Boolean logic as it appears in Ruby and Rails code. It starts with propositions, the two values true and false, and the origins in the work of George Boole and Claude Shannon. It then covers AND, OR, NOT and XOR, short-circuit evaluation, and Ruby truthiness. Later lessons build truth tables, apply operator precedence and De Morgan's laws, and simplify expressions. The last lesson applies these ideas to boolean columns, scopes, validations, callbacks, views, policy objects and tests.

What you'll learn

  • ✓How AND, OR, NOT and XOR work and their truth tables
  • ✓Short-circuit evaluation and the difference between && and and, || and or
  • ✓Ruby truthiness, the !! pattern and when to use unless
  • ✓Building truth tables to prove equivalence and find logic bugs
  • ✓Operator precedence, De Morgan's laws and simplification laws
  • ✓Boolean logic in Rails scopes, validations, callbacks, views and policy objects
Free preview · Lesson 1 5 min read

What is boolean logic?

Every time your code makes a decision, it uses Boolean logic: a system where everything is reduced to two values: true or false.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...