These are chat archives for andela/andela-21-lite

8th
Jun 2016
clarch
@clarch
Jun 08 2016 08:03
This message was deleted
clarch
@clarch
Jun 08 2016 08:14

@andela-engmkwalusimbi ahh thanks for the clarification mahad. Ok so tell me why this also works

class Person:
    age=0
    def __init__(self,initialAge):
        # Add some more code to run some checks on initialAge
         if (initialAge < 1):
             print("Age must be above 0")
         self.age = initialAge
      def  yearPasses():
          self.age = self.age + 1

shouldn't we reference class variables as in this case:

def yearPasses():
    Person.age = Person.age + 1

or is it the same thing and why or how is it interchangable

sorry for mine I assigned self.age = initialAge before the if statement in init like so
class Person:
    age=0

    def __init__(self,initialAge):
        # Add some more code to run some checks on initialAge
        self.age = initialAge
         if (self.age < 1):
             print("Age must be above 0")

      def  yearPasses():
          self.age = self.age + 1
Michael Gichia
@michaelgichia
Jun 08 2016 09:13
@andela-engmkwalusimbi cheers there.