Questions
Ruby questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Rails before_action vs before_filter: What's the Difference in Rails 4?
Learn the difference between before_action and before_filter in Rails 4, why Rails changed the name, and how callbacks work in controllers.
Rails includes vs joins: Understanding Eager Loading and SQL Joins in ActiveRecord
Learn the difference between Rails includes and joins, why includes may run separate queries, and when ActiveRecord uses joins.
Rails update_attributes Without Saving: How to Assign Multiple Attributes First
Learn how to update multiple ActiveRecord attributes in Rails without saving yet, using assign_attributes and mass assignment safely.
Read File Lines in Ruby: Handle LF, CRLF, and CR Endings
Learn Ruby file line reading, stdin streams, and reliable LF, CRLF, and CR newline handling with practical examples and pitfalls.
Remove Duplicate Elements from an Array in Ruby
Learn how to remove duplicate values from a Ruby array using built-in methods like uniq and uniq! with clear examples and common pitfalls.
Remove Empty Strings from an Array in JavaScript
Learn how to remove blank elements from a JavaScript array using filter(), truthy checks, and safe patterns for real projects.
Remove a Key from a Hash in Ruby: delete vs reject and Returning the Remaining Hash
Learn how to remove keys from a Ruby Hash using delete, reject, except, and non-mutating patterns with clear examples and common pitfalls.
Remove the First Array Element in Ruby: shift, drop, and Slicing
Learn how to remove the first element from a Ruby array using shift, drop, and slicing, including mutation rules, examples, and common pitfalls.
Remove the Last N Characters from a Ruby String
Learn preferred Ruby techniques for removing the last N characters from strings, including slicing, mutation, edge cases, and Unicode safety.
Ruby &: Symbol-to-Proc Shortcut Explained
Learn why `&:foo` works in Ruby, how Symbol-to-Proc conversion happens, and when to use it instead of a normal block.
Ruby <=> Spaceship Operator: Comparison and Comparable
Learn how Ruby’s <=> spaceship operator compares values, returns ordering results, powers Comparable, and differs from other languages.
Ruby Bang Methods Explained: What ! Means in Ruby Method Names
Learn what exclamation marks mean in Ruby method names, when bang methods are used, and how they differ from non-bang methods.
Ruby Blocks and yield: A Beginner’s Guide
Learn how Ruby blocks and yield work, including arguments, return values, block_given?, and how Rails layouts use yield for view content.
Ruby Equality Methods Explained: equal?, eql?, ==, and ===
Learn the difference between Ruby's equal?, eql?, ==, and ===, with examples, semantics, and when each method is used.
Ruby Gemfile `require: false` Explained
Learn what `require: false` means in a Ruby Gemfile, how Bundler loads gems, and when to use it in real Ruby projects.
Ruby Integer Division: Why 9 / 5 Returns 1 and How to Get Decimals
Learn why Ruby divides two integers using integer division, why 9 / 5 returns 1, and how to get decimal results with floats or fdiv.
Ruby Loop Control: The Equivalent of continue in Ruby
Learn the Ruby equivalent of continue, how `next` works in loops, and when to use it with clear examples and common mistakes.
Ruby Loops: Alternatives to a do...while Loop in Ruby
Learn how to replace a do...while loop in Ruby using begin...end while, loop do, and input patterns for cleaner code.
Ruby Modules vs Classes: What’s the Difference and When to Use Each?
Learn the difference between Ruby modules and classes, when to use each, and how modules help with namespacing and shared behavior.
Ruby Multi-Line Strings Without Concatenation
Learn how to write multi-line strings in Ruby without messy concatenation, including heredoc, adjacent literals, and readable SQL examples.