Questions
Ruby questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Ruby print vs puts: Output and Newlines Explained
Learn the difference between Ruby print and puts, including newline behavior, return values, loop output, and practical examples.
Ruby require vs require_relative: Differences and Usage
Learn the difference between Ruby require and require_relative, how load paths and working directories affect them, and when to use each.
Run a Single Laravel Migration File Safely
Learn how to run one Laravel migration file with Artisan, understand migration tracking, dependencies, rollback behavior, and safer alternatives.
Run a Single RSpec Spec File in Ruby
Learn how to run one RSpec spec file, a single example, or a tagged group in Ruby projects using bundle exec rspec and line filters.
Search an Array of Hashes by Value in Ruby with select
Learn how to filter an array of hashes in Ruby using Enumerable#select, block conditions, string keys, and practical examples.
Shell Languages vs Scripting Languages: Why Bash Feels Different from Python
Learn why shell languages like Bash differ from Python, Perl, and Ruby, and what makes shells better for command-line tasks.
Should Gemfile.lock Be Committed in Ruby? A Beginner-Friendly Guide
Learn when to commit Gemfile.lock in Ruby projects, when to ignore it, and how Bundler uses it for consistent dependencies.
Sort a Hash by Key and Return a Hash in Ruby
Learn how to sort a Ruby Hash by key, rebuild it as a Hash, understand insertion order, and choose safe sorting patterns for real code.
Sort an Array of Hashes in Descending Order in Ruby
Learn how to sort a Ruby array of hashes by a key in descending order using sort_by, reverse, and custom comparators.
Split Long String Literals Across Lines in Ruby Without Newlines
Learn how Ruby concatenates adjacent string literals, letting you wrap long strings across source lines without adding newlines or runtime work.
Understanding Ruby's Double-Colon :: Operator
Learn what Ruby's :: operator does, how constants and namespaces work, and why it does not bypass private or protected access rules.
Understanding `class << self` in Ruby
Learn what `class << self` means in Ruby, how it works, when to use it, and how it compares to other ways of defining class methods.
Understanding nil?, empty?, and blank? in Ruby and Rails
Learn the difference between nil?, empty?, and blank? in Ruby on Rails with examples, comparisons, common mistakes, and practical usage.
Understanding the Rails Authenticity Token in Ruby on Rails
Learn what the Rails authenticity token is, why it exists, and how it protects forms from CSRF attacks in Ruby on Rails apps.
Update One Gem with Bundler in Ruby and Rails
Learn how to update one Ruby gem with Bundler, including Git-based gems, lockfiles, dependency rules, and safe Rails commands.
What %w Means in Ruby: Array of Strings Syntax Explained
Learn what %w means in Ruby, how it creates arrays of strings, when to use it, and how it compares to normal array syntax.
What `map(&:name)` Means in Ruby
Learn what `map(&:name)` means in Ruby, how `&:` works with `map`, and how it compares to block syntax in real Ruby and Rails code.
What attr_accessor Means in Ruby: Getters and Setters Explained
Learn what attr_accessor does in Ruby, how it creates getters and setters, and when to use attr_reader or attr_writer instead.
What ||= Means in Ruby: Understanding the Or-Equals Operator
Learn what ||= means in Ruby, how it works with nil and false, and when to use it for default values, memoization, and cleaner code.
When to Use RSpec let vs before in Ruby Tests
Learn the difference between RSpec let and before in Ruby. Understand lazy evaluation, memoization, setup patterns, and when to use each.