Ruby idioms

Programming idioms in Ruby.

Memoization

Memoized methods:

class MyClass
  def result
    @result ||= calculate_result
  end

  def nullable_result
    return @nullable_result if defined?(@nullable_result)

    @nullable_result = calculate_result
  end
end