I'm doing the code academy stream and I have a little experience in Ruby. I don't understand why the check_angles(self)
function needs the self
parameter.
The reason I'm confused is that I don't understand what is passing the self parameter to the function when it is called. it seems like the function call (the last line of the code block) is passing self implicitly, but the function requires self explicitly defined as a parameter.
Why is this?
class Triangle(object):
def __init__(self, angle1, angle2, angle3):
self.angle1 = angle1
self.angle2 = angle2
self.angle3 = angle3
number_of_sides = 3
def check_angles(self):
sum_angles = self.angle1 + self.angle2 + self.angle3
if sum_angles == 180:
return True
else:
return False
tri = Triangle(45,34,78)
tri.check_angles(EMPTY BUT WHY)