Ruby Interview | Ruby on Rails – Telegram
Ruby Interview | Ruby on Rails
476 subscribers
14 photos
2 links
The Ruby Interview channel is a resource for preparing for Ruby developer interviews.

It features questions, problem-solving solutions, and interview tips.

Contact:
@Connor_1992
Download Telegram
Which of the following URLs is the most RESTful for fetching a specific order with ID 42?
Anonymous Quiz
3%
/getOrder?id=42
67%
/orders/42
5%
/order?id=42
26%
/api/v1/orders?id=42
Which operator is used for string interpolation?
Anonymous Quiz
8%
+
2%
%
89%
#{}
1%
@{}
The quiz will be in 1 minute 👇
What will this Ruby code return?
Anonymous Quiz
1%
3
90%
8
8%
Error
0%
5
Which of the following code snippets correctly checks if a number is even in Ruby?
Anonymous Quiz
27%
if number % 2 == 0
2%
if number == even?
70%
if number.even?
1%
if number.even
👍5
What will this code output?
Anonymous Quiz
12%
true
80%
false
1%
5
7%
Error
Which values are considered falsy in Ruby?
Anonymous Quiz
7%
0
3%
" (empty string)
3%
[] (empty array)
88%
nil and false
🔥 Battle City 3 — a game that’s growing more popular every day

🎮 Online seasons, tank selection, and awesome rewards: grenades, enemy freeze, extra lives, and more

🌐 New online levels are added regularly — there's always something fresh to play!

📴 Prefer offline? Enjoy 12 levels with selectable difficulty

📲 Download now and jump into the battle!
👇👇👇
https://battlecity.udfsoft.com?from=tg_rubyI
https://battlecity.udfsoft.com?from=tg_rubyI
1💩6🔥2
What will this code output?

puts "apple" < "banana"
Anonymous Quiz
59%
true
17%
false
4%
nil
19%
Error
What is the result?
What is the result?☝️
Anonymous Quiz
23%
[1, 2, 3]
73%
[1, 2, 3, 4]
1%
nil
3%
Error
Which HTTP method is used to partially update a resource?
Anonymous Quiz
14%
PUT
78%
PATCH
8%
UPDATE
0%
POST
Which status code means unauthorized access?
Anonymous Quiz
82%
401 Unauthorized
17%
403 Forbidden
1%
404 Not Found
0%
400 Bad Request
🔍 Understanding Ruby Blocks, Procs, and Lambdas

One of Ruby’s most elegant — yet initially confusing — features is its support for blocks, Procs, and lambdas. Mastering these is key to writing idiomatic and powerful Ruby code.

🧱 What is a Block?
A block is an anonymous piece of code that can be passed to a method.

def greet
yield
end

greet { puts "Hello from the block!" }
# => Hello from the block!


If you call yield without a block, Ruby raises an error — unless you check with block_given?.

🎁 What is a Proc?
A Proc is a block saved into a variable.

say_hello = Proc.new { puts "Hello!" }
say_hello.call
# => Hello!

You can pass Procs to methods, return them, and store them — like any object.

🧠 What is a Lambda?
A lambda is a special kind of Proc with stricter argument checking and different return behavior.

greet = lambda { |name| puts "Hello, #{name}!" }
greet.call("Rubyist")
# => Hello, Rubyist!


Key differences:
- lambda enforces argument count (unlike Proc)
- return in a lambda exits only the lambda; in a Proc, it exits the method it's called from

🆚 Proc vs Lambda: Subtle but Important

def test
proc = Proc.new { return "From Proc" }
proc.call
return "After Proc"
end

puts test
# => "From Proc" (method exited early)

def test_lambda
l = -> { return "From Lambda" }
l.call
return "After Lambda"
end

puts test_lambda
# => "After Lambda" (lambda returned only from itself)


When to Use What?
- Use blocks for simple callbacks or iteration (e.g., each, map)
- Use Procs when you need to store logic to reuse
- Use lambdas when return behavior and argument count matter

🔹 Learning to use blocks, Procs, and lambdas fluently is a big step toward writing expressive Ruby code.

#rubyonrails #codingtips
1🔥16👍2