What is the recommended format for resource names in RESTful APIs?
Anonymous Quiz
8%
PascalCase (e.g., /UserAccounts)
11%
camelCase (e.g., /userAccounts)
64%
snake_case (e.g., /user_accounts)
17%
kebab-case and plural (e.g., /user-accounts)
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
What is a common use of the HTTP PATCH method in REST APIs?
Anonymous Quiz
10%
Completely replace a resource
0%
Delete a resource
88%
Partially update a resource
2%
Create a new resource
What does require 'json' do?
Anonymous Quiz
4%
Loads a JSON file
86%
Includes the library for working with JSON
4%
Creates a JSON object
5%
Parses a JSON string
👍2
Which of the following is the correct syntax for a ternary operator in Ruby?
Anonymous Quiz
97%
condition ? value1 : value2
3%
if condition then value1 else value2
0%
if condition { value1 else value2 }
0%
condition ? value1 : value2 else value3
Forwarded from Ruby Interview | Ruby on Rails
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
Forwarded from Ruby Interview | Ruby on Rails
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
🎮 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"
puts "apple" < "banana"
Anonymous Quiz
59%
true
17%
false
4%
nil
19%
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
What does the HTTP status code 304 Not Modified mean?
Anonymous Quiz
5%
The resource was not found
85%
The resource has not changed since the last request
6%
The request was invalid
3%
The server is overloaded
🔍 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.
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.
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.
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
✅ 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
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