Youssef Kaib Youssef Kaib - 2 months ago 7
Ruby Question

Ruby: Refactoring a method to predicted method

I'm new to ruby. please help, I need to refactor to boolean function return true or false

def equilateral()
return side1 == side2 && side2 == side3
end


I tried and did not work.

def equilateral?
if side1 == side2 && side2 == side3
end


Any help would be highly appreciated.

Answer

Alternately, you could write it like this and leave out the return statement...

Edit Update

def equilateral
  side1 == side2 && side2 == side3
end