Ruby Interview | Ruby on Rails
484 subscribers
15 photos
3 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
What is the result?☝️
Anonymous Quiz
25%
[1, 2, 3]
72%
[1, 2, 3, 4]
1%
nil
3%
Error
❀1
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
83%
401 Unauthorized
16%
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❀1
What does this code output?

puts "πŸ‰" * 3
Anonymous Quiz
3%
πŸ‰3
88%
"πŸ‰πŸ‰πŸ‰"
1%
"3πŸ‰"
7%
Error
1πŸ‘2😱1
Which header controls cross-origin resource sharing (CORS)?
Anonymous Quiz
9%
Authorization
3%
User-Agent
85%
Access-Control-Allow-Origin
2%
Content-Length
What’s the main drawback of monolithic architecture in Ruby on Rails applications?
Anonymous Quiz
2%
No database support
67%
Harder to test small parts of the system
28%
Ruby cannot scale monoliths at all
3%
Controllers cannot talk to models
Forwarded from Android frameworks
🌑 WiFi Temperature Sensor (ESP32 + DHT11)

A simple IoT temperature and humidity sensor based on ESP32-C3 and DHT11.
The device measures temperature and humidity, sends the data to a backend server, and from there it can be forwarded, for example, to a Telegram bot.

https://github.com/UDFSoft/Wifi-Temp-Sensor/
1πŸ‘2❀1πŸ‘1
What will this code print?
puts "2 + 2 = #{2 + 2}"
Anonymous Quiz
4%
2 + 2 = 2 + 2
2%
2 + 2 = 22
92%
2 + 2 = 4
2%
Error
Which header is used to send authentication tokens in REST APIs?
Anonymous Quiz
9%
Content-Type
3%
Accept
85%
Authorization
3%
Cookie
Ruby in 2025 πŸ’Ž

Ruby in 2025 stayed calm and mature.
No hype, no drama β€” just stable, readable, productive code.

πŸš€ Performance kept improving (YJIT)
πŸ›€ Rails focused on Hotwire and boring, reliable architecture
πŸ— More modular monoliths, fewer unnecessary microservices
πŸ§ͺ Cleaner code, fewer callbacks, more explicit logic

Ruby isn’t trendy anymore β€” and that’s its strength.
It’s a language for teams who value clarity, stability, and long-term maintenance ❀️
1πŸ”₯16❀4πŸ₯°3
What is the correct way to handle a ZeroDivisionError in Ruby?
Anonymous Quiz
49%
using rescue
8%
using raise
37%
using begin and rescue
6%
using catch