Answers for "explicit return in __init_"

0

explicit return in __init_

class Rectangle(object):
    def __init__(self, width, height):
        self.width = width
        self.height = height
        self._area = width * height

    @property
    # moved the logic for returning area to a separate method
    def area(self):
        return self._area
Posted by: Guest on September-27-2020
0

explicit return in __init_

class Rectangle:
    def __init__(self, width, height):
        self.width = width
        self.height = height
        self.area = width * height
        # return statement removed from here
Posted by: Guest on September-27-2020

Browse Popular Code Answers by Language