← Back to Ruby Course | Chapter 4: Arrays | Lesson 6 of 7

Array Methods

In this page:

  1. Array Methods

Array Methods

Ruby arrays have dozens of useful built-in methods beyond the basics, like .sort, .uniq, .include?, .sum, .min, .max, and .first/.last. Most of these come from the Enumerable module that Array includes, so they're also available on other collection types like Hash and Range. Learning these built-ins is key to writing concise, idiomatic Ruby instead of manual loops.

Note: Because Array includes Enumerable, methods like sum, min, and sort also work on any custom class that includes Enumerable.

Example: Array Methods

markup
numbers = [5, 3, 8, 1, 9, 3]

puts numbers.sort.inspect
puts numbers.uniq.inspect
puts numbers.include?(8)
puts numbers.sum
puts numbers.max
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.