Ruby Basics Part 2 — Hashes, Arrays, Iterators, String Manipulation
ruby
dev.to
Last post covered variables, methods, blocks, and classes. Now let's talk about the data structures you'll actually use every day: arrays, hashes, and the iterators that make them powerful. Arrays: Ordered Lists models = ["gpt-4", "claude-3", "gemini"] models[0] # => "gpt-4" models[-1] # => "gemini" models.length # => 3 models.first # => "gpt-4" models.last # => "gemini" Adding and removing: models "llama-3" # append models.pu