Advanced Ruby • Exercise 5/5

Endless Method

00:00
0
15 points

Instructions

Ruby 3.0+ introduced endless method definitions for simple one-liner methods.

Instead of:
ruby
def double(x)
x * 2
end

You can write:
ruby
def double(x) = x * 2

Create a module MathHelpers with these endless methods:
1. square(n) - returns n squared
2. cube(n) - returns n cubed
3. average(a, b) - returns average of two numbers

Your Code

Results

Click "Run Tests" to see results