Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Extend other structs

struct Int
  def prime?
    (2..(self ** 0.5).to_i).each { |num|
      return false if self % num == 0
    }
    return true
  end
end

puts 23.odd?
puts 23.even?
puts 23.prime?
puts 20.prime?