Questions

Ruby questions

Choose a question page, learn the concept, then test your understanding with a quiz.

How to Iterate Through an Array in Ruby: each, each_with_index, for, and More

Learn the right way to iterate through arrays in Ruby, including each, each_with_index, times, and hash iteration patterns.

rubyarraysloops

How to Map and Remove nil Values in Ruby

Learn idiomatic Ruby ways to transform arrays and remove nil values using map, compact, filter_map, and related patterns.

ruby

How to Map with Index in Ruby

Learn how to transform arrays with both value and index in Ruby using map.with_index, each_with_index, and practical examples.

rubyarraysindexing

How to Match All Regular Expression Occurrences in Ruby

Learn how to find every regex match in Ruby using scan, to_enum, and MatchData with clear examples and common pitfalls.

rubyregex

How to Parse a JSON String in Ruby

Learn how to parse a JSON string in Ruby, access nested values safely, and avoid common mistakes with practical examples.

rubyjson

How to Pass Command Line Arguments to a Rake Task in Ruby

Learn how to pass command line arguments to Rake tasks in Ruby, including task parameters, environment variables, and calling tasks from other tasks.

rubycommand-linerakecommand-line-arguments

How to Pause Execution in Ruby with sleep

Learn how to make a Ruby program wait using sleep, including syntax, examples, timing behavior, and common mistakes.

rubysleep

How to Pick a Random Element from an Array in Ruby

Learn how to choose a random item from an array in Ruby using Array#sample, with examples, mistakes to avoid, and practical use cases.

rubyarraysrandom

How to Remove Old Ruby Gem Versions and Keep the Latest

Learn how to uninstall old Ruby gem versions while keeping the newest one using RubyGems commands and safe cleanup practices.

rubyrubygems

How to Remove RVM (Ruby Version Manager) from Your System

Learn how to remove RVM from your system safely, including shell cleanup, PATH changes, and verifying Ruby environment settings.

rubyrubygemsrvm

How to Remove Whitespace in Ruby: strip, lstrip, rstrip, and gsub

Learn how to remove whitespace in Ruby using strip, lstrip, rstrip, and gsub, and how they compare to PHP trim().

rubystring

How to Remove an Array Element by Value in Ruby

Learn how to delete an element from an array by value in Ruby using delete, delete_at, reject, and related array methods.

rubyarrays

How to Replace a Word in a String in Ruby

Learn how to replace a word in a Ruby string using sub and gsub, with simple examples, common mistakes, and practical use cases.

rubyruby-on-rails-3

How to Require All Files from a Directory in Ruby

Learn how to require all files from a directory in Ruby using Dir globbing, require_relative, load order, and common pitfalls.

rubyfiledirectoryrequire

How to Return a 404 Response in Ruby on Rails

Learn how to return or render a 404 response in Rails, when to use it, and common patterns for missing records and custom not found pages.

rubyruby-on-railshttphttp-status-code-404

How to Round an Average to 2 Decimal Places in PostgreSQL

Learn why ROUND(AVG(...), 2) can fail in PostgreSQL and how to correctly round averages to 2 decimal places using numeric casting.

rubysqlpostgresqlsequel

How to Run One Rake Task from Another in Ruby

Learn how to run Rake tasks from within other Rake tasks in Ruby, including prerequisites, reenable, invoke, and common pitfalls.

rubyrake

How to Run a Single RSpec Test in Rails

Learn how to run one RSpec file or a single example in Rails, including terminal commands, line numbers, and project directory setup.

rubyruby-on-railsruby-on-rails-3rspec

How to Skip an Iteration in Ruby .each: Using next Instead of continue

Learn how to skip an iteration in a Ruby .each loop using next, with examples, common mistakes, comparisons, and practice exercises.

rubyloopssyntaxiteration

How to Sum an Array of Numbers in Ruby

Learn how to sum numbers in a Ruby array using sum, inject, and each, with examples, common mistakes, and a practical mini project.

rubyarraysmathsum

Page 3 of 6 - 112 questions