The Elements of Style in Ruby #8: Know Thy Predicates
I often see people writing code like this: if x % 2 == 0 ... Obviously Fixnum#even? would have been a better choice: if x.even? ... There is also Fixnum#odd? if you need to check for odd numb...
I often see people writing code like this: if x % 2 == 0 ... Obviously Fixnum#even? would have been a better choice: if x.even? ... There is also Fixnum#odd? if you need to check for odd numb...
Prelude In the last few days Paul Stamatiou’s article Android is Better and Marco Arment’s excellent response Google Blindness have been generating a lot of heated debates. This article is pretty ...
Today we’ll discuss the following section from the Ruby Style Guide: Avoid explicit use of the case equality operator ===. As it name implies it’s meant to be used implicitly by case expression...
Today we’ll talk about attributes in Ruby. Let’s start with the following rule from the Ruby Style Guide: Use the attr family of functions to define trivial accessors or mutators. Everyone w...
Today’s topic is the following rule from the Ruby Style Guide: Add underscores to large numeric literals to improve their readability. Most of the programs we write feature a substantial numb...
RuboCop 0.9 is finally out! This was one of our most ambitious releases - over a month of work, ~250 commits, lots of new cops and features and a lot less bugs.1 Here’s the highlights. Portable Li...
Today’s topic is the following rule from the Ruby Style Guide: Favor the use of Array#join over the fairly cryptic Array#* with a string argument. Array#join and Array#* (with a string argume...
The subject of today’s post is the following rule from the Ruby Style Guide: Use [*var] or Array() instead of an explicit Array check, when dealing with a </br> variable you want to treat...
Today’s topic is the following rule from the Ruby Style Guide: Favor the use of sprintf and its alias format over the fairly </br> cryptic String#% method. Kernel#sprintf and String#% b...
Welcome to the first installment of The Elements of Style in Ruby. We’ll start off with something pretty generic, that’s not specific to Ruby at all - the maximum line length that’s acceptable in ...