Pattern Matching • Exercise 2/4

Hash Pattern Matching

00:00
0
25 points

Instructions

Create a function greet_user that takes a user hash and returns
a greeting based on the user's role.

Use hash pattern matching:
ruby
case user
in { name:, role: "admin" }
"Welcome back, Admin #{name}!"
in { name: }
"Hello, #{name}!"
end

Your Code

Results

Click "Run Tests" to see results