
Ruby Basics
Variables, data types, control flow, methods, blocks, procs, lambdas
1What is the difference between a local variable and an instance variable in Ruby?
What is the difference between a local variable and an instance variable in Ruby?
Câu trả lời
A local variable starts with a lowercase letter or underscore and is only accessible within its scope (method or block). An instance variable starts with @ and is accessible in all methods of the object, persisting throughout the instance's lifetime. This distinction is fundamental for state management in Ruby objects.
2How to declare a constant in Ruby and what is its naming convention?
How to declare a constant in Ruby and what is its naming convention?
Câu trả lời
In Ruby, a constant is declared using a name starting with an uppercase letter. By convention, constants are written in SCREAMING_SNAKE_CASE (e.g., MAX_SIZE = 100). Ruby emits a warning if a constant is modified, but doesn't prevent it unlike other languages.
3What is the result of the expression 5 / 2 in Ruby and how to get a decimal result?
What is the result of the expression 5 / 2 in Ruby and how to get a decimal result?
Câu trả lời
In Ruby, division between two integers (Integer) returns an integer (5 / 2 = 2). To get a decimal result, at least one operand must be a Float: 5.0 / 2 or 5 / 2.0 or 5.to_f / 2. This rule follows the integer division principle present in many languages.
What is the difference between a Symbol (:name) and a String ("name") in Ruby?
How does string interpolation work in Ruby?
+22 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Ruby on Rails khác
Ruby Object-Oriented Programming
Rails Fundamentals
Routing & Controllers
ActiveRecord Basics
Views & ERB Templates
ActiveRecord Associations
Advanced ActiveRecord Queries
Rails Forms
Authentication & Authorization
Modern Asset Pipeline & Frontend
Rails API Mode
Testing with RSpec
ActiveJob & Background Jobs
ActionCable & WebSockets
ActionMailer
ActiveStorage
Caching Strategies
Advanced Migrations
Rails Engines & Modular Apps
Performance Optimization
Rails Design Patterns
Ruby Metaprogramming
Rails Security
GraphQL with Rails
Deployment & Production
Monitoring & Logging
Rails Upgrade Strategies
Nắm vững Ruby on Rails cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí