LearnThatStack Ace your next interview
Backend Development

Ruby.

Start free Change topic Change
Practice · Questions

All questions

Showing of 85
Beginner 13
01

What is the difference between nil, empty, and blank in Ruby?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • nil: Represents "nothing" or "no value". Only nil object responds true to .nil?
  • empty: A method that returns true for collections with no elements (arrays, hashes, strings)
  • blank: Rails addition that returns true for nil, empty collections, and whitespace-only strings
nil.nil?        # true
"".empty?       # true
[].empty?       # true
" ".blank?      # true (Rails only)
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

Explain the difference between single quotes and double quotes in Ruby strings.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Double quotes allow string interpolation and escape sequences, while single quotes treat most characters literally (except for \' and \\).

name = "Alice"
puts "Hello #{name}"   # "Hello Alice"
puts 'Hello #{name}'   # "Hello #{name}"
puts "Line\nBreak"     # Line with actual break
puts 'Line\nBreak'     # "Line\nBreak" literally
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What are symbols in Ruby and when should you use them?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Symbols are immutable, reusable constants represented internally by an integer value. They're often used as hash keys, method names, or status identifiers because they're memory-efficient - the same symbol always references the same object in memory.

:status.object_id == :status.object_id  # true
"status".object_id == "status".object_id  # false
# Common usage
user = { name: "John", age: 30 }  # symbols as hash keys
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What is the difference between puts, print, and p in Ruby?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • puts: Outputs value with newline, returns nil, calls .to_s
  • print: Outputs value without newline, returns nil, calls .to_s
  • p: Outputs inspected value with newline, returns the value, calls .inspect
puts "Hello"    # Hello\n (returns nil)
print "Hello"   # Hello (returns nil)
p "Hello"       # "Hello"\n (returns "Hello")
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What are the three levels of access control for methods in Ruby?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • public: Can be called from anywhere (default)
  • protected: Can be called by instances of the same class or subclasses
  • private: Can only be called within the same instance (no explicit receiver)
class MyClass
  def public_method; end
  
  protected
  def protected_method; end
  
  private
  def private_method; end
end
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What is the difference between Array#map and Array#each?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • each: Iterates through elements, returns original array, used for side effects
  • map: Transforms elements, returns new array with transformed values
numbers = [1, 2, 3]
numbers.each { |n| n * 2 }  # Returns [1, 2, 3]
numbers.map { |n| n * 2 }   # Returns [2, 4, 6]
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

Explain the difference between Hash#merge and Hash#merge!

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • merge: Returns a new hash with combined key-value pairs
  • merge!: Modifies the original hash in place (destructive)
h1 = { a: 1, b: 2 }
h2 = { b: 3, c: 4 }
h1.merge(h2)   # Returns { a: 1, b: 3, c: 4 }, h1 unchanged
h1.merge!(h2)  # h1 is now { a: 1, b: 3, c: 4 }
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

Explain the difference between Array#flatten and Array#compact.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • flatten: Removes nested array structure, creating a single-level array
  • compact: Removes nil values from array
[[1, 2], [3, [4]]].flatten  # [1, 2, 3, 4]
[1, nil, 2, nil, 3].compact  # [1, 2, 3]
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

09

Explain the Rails MVC architecture.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

MVC separates application into three components:

  • Model: Handles data and business logic (ActiveRecord)
  • View: Presents data to users (ERB templates)
  • Controller: Coordinates between Model and View, handles requests

The flow: Request → Router → Controller → Model → Controller → View → Response

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

10

What are Ruby's naming conventions?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • Classes/Modules: CamelCase (UserAccount)
  • Methods/Variables: snake_case (user_name)
  • Constants: SCREAMING_SNAKE_CASE (MAX_USERS)
  • Predicates: end with ? (empty?)
  • Dangerous methods: end with ! (save!)
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

11

What is the purpose of Gemfile and Gemfile.lock?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • Gemfile: Specifies gem dependencies and sources
  • Gemfile.lock: Locks specific versions for consistent environments

Both ensure all developers and deployment environments use identical gem versions.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

12

What is the safe navigation operator (&.) and when should you use it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

The safe navigation operator (&.) calls methods only if the receiver is not nil, preventing NoMethodError on nil objects.

user&.profile&.name  # Returns nil if any part is nil
# Equivalent to:
user && user.profile && user.profile.name

# With arrays
users&.first&.name  # Safe even if users is nil
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

13

What is the rightward assignment operator in Ruby 3?

Part of Pro
Intermediate 49
14

Explain the difference between == and === in Ruby.

Part of Pro
15

What is the difference between a class and a module in Ruby?

Part of Pro
16

Explain the concept of Duck Typing in Ruby.

Part of Pro
17

What is the difference between instance variables and class variables?

Part of Pro
18

Explain method visibility inheritance in Ruby.

Part of Pro
19

What is the purpose of super keyword in Ruby?

Part of Pro
20

What is method aliasing and when would you use it?

Part of Pro
21

What is the difference between Array#select, Array#reject, and Array#partition?

Part of Pro
22

How does the Enumerable module work in Ruby?

Part of Pro
23

What is the spaceship operator (<=>) and how is it used?

Part of Pro
24

What is the difference between yield and block.call?

Part of Pro
25

Explain the & operator in method parameters.

Part of Pro
26

What is method chaining and how do you implement it?

Part of Pro
27

What are keyword arguments and how do they differ from positional arguments?

Part of Pro
28

What is the splat operator (*) and double splat (**)?

Part of Pro
29

What is the difference between include, prepend, and extend?

Part of Pro
30

What is the purpose of module_function?

Part of Pro
31

How do you handle module name conflicts?

Part of Pro
32

What is the difference between raise and throw in Ruby?

Part of Pro
33

Explain the structure of begin-rescue-else-ensure-end.

Part of Pro
34

How do you create custom exception classes?

Part of Pro
35

What is the difference between File.open and File.new?

Part of Pro
36

How do you handle file operations safely in Ruby?

Part of Pro
37

What is the difference between require and load?

Part of Pro
38

Explain the difference between system, exec, and backticks for running shell commands.

Part of Pro
39

What is the difference between stub and mock in testing?

Part of Pro
40

What is the purpose of fixtures and factories in testing?

Part of Pro
41

What debugging techniques are available in Ruby?

Part of Pro
42

What is the difference between render and redirect_to in Rails?

Part of Pro
43

What are Rails callbacks and when should you use them?

Part of Pro
44

What is the N+1 query problem and how do you solve it?

Part of Pro
45

What is the difference between concerns and services in Rails?

Part of Pro
46

Explain strong parameters in Rails.

Part of Pro
47

What is the difference between has_many :through and has_and_belongs_to_many?

Part of Pro
48

Explain database transactions in Rails.

Part of Pro
49

What are scopes in ActiveRecord and how do they differ from class methods?

Part of Pro
50

Explain the difference between delete and destroy in ActiveRecord.

Part of Pro
51

What is the difference between lazy and eager evaluation?

Part of Pro
52

How do you securely handle sensitive data in Ruby?

Part of Pro
53

What is the Singleton pattern and how is it implemented in Ruby?

Part of Pro
54

What is the difference between composition and inheritance?

Part of Pro
55

What is the Law of Demeter and how does it apply to Ruby?

Part of Pro
56

What is the difference between fail-fast and fail-safe approaches?

Part of Pro
57

What is pattern matching in Ruby and how does it work?

Part of Pro
58

What are endless method definitions in Ruby 3?

Part of Pro
59

What are numbered block parameters?

Part of Pro
60

Explain keyword argument separation in Ruby 3.0

Part of Pro
61

What is the ... (three dots) operator for argument forwarding?

Part of Pro
62

What is the difference between then, yield_self, and tap?

Part of Pro
Expert 23
63

What is the difference between a block, proc, and lambda?

Part of Pro
64

Explain the Ruby method lookup chain.

Part of Pro
65

What is the difference between rescue StandardError and rescue Exception?

Part of Pro
66

What is the purpose of Rails middleware?

Part of Pro
67

What is optimistic locking in Rails?

Part of Pro
68

What are the common performance optimization techniques in Ruby?

Part of Pro
69

How do you profile Ruby code performance?

Part of Pro
70

What is memory leak in Ruby and how do you prevent it?

Part of Pro
71

What is metaprogramming in Ruby?

Part of Pro
72

Explain method_missing and how to use it safely.

Part of Pro
73

What is the difference between class_eval and instance_eval?

Part of Pro
74

What are singleton methods and singleton classes?

Part of Pro
75

What is the Global Interpreter Lock (GIL) in Ruby?

Part of Pro
76

What is the difference between Thread and Fiber in Ruby?

Part of Pro
77

How do you handle thread safety in Ruby?

Part of Pro
78

What are common security vulnerabilities in Ruby applications?

Part of Pro
79

Explain the SOLID principles in context of Ruby.

Part of Pro
80

What is Rack and why is it important?

Part of Pro
81

Explain the concept of Dependency Injection in Ruby.

Part of Pro
82

How does Ruby's garbage collection work?

Part of Pro
83

What is refinement in Ruby?

Part of Pro
84

What are Ractors and how do they enable true parallelism?

Part of Pro
85

What are Fiber Scheduler and async I/O in Ruby 3?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Ruby? Send them this set.
Pro · $10/mo

73 of 85 Ruby answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git