I am trying to create a method that returns the length of a rectangle/square diagonal as a float. However, my method diagonal
doesn't seem to work as intended. I guess I have hit a road block and would like to see if any of you had an idea on how I could approach this problem.
class Rectangle
def initialize(width, length)
@width = width
@length = length
end
def perimeter
2*(@length + @width)
end
def area
@length * @width
end
def diagonal
# measure = Math.hypot(@length, @width)
measure = (@length.to_f ** 2) + (@width.to_f ** 2)
measure.hypot(@length, @width)
end
end