You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deffunction_1(parameter_1:int): # defining a function with 1 parameter (int type)
181
181
print("function 1")
182
182
183
-
deffunction_2(parameter_1:int,parameter_2:str): # defining a function with 2 parametrs (int,str types)
183
+
deffunction_2(parameter_1:int,parameter_2:str): # defining a function with 2 parameters (int,str types)
184
184
print("function 2")
185
185
186
186
delegate = Delegate() #creating a Delegate
@@ -628,9 +628,9 @@ It is **HIGHLY IMPORTANT** to realize *moved* event signature is *Callable[[obje
628
628
-*Callable[[object, MovedEventArgs], None]*
629
629
-*Callable[[object, EventArgs], None]*
630
630
631
-
This 2 signatures are ok due polimorfism, it can be confusing due at first sight seems like we are asigning an *EventArgs* objeect to a *MovedEventArgs* variable (*MovedEventArgs*<-*EventArgs*), this case in OOP (Object Oriented programming) isnot valid, due it might throw a Traceback if a *MovedEventArgs* member is trying to be accessed in a *EventArgs*object.
631
+
This 2 signatures are ok due polymorphism, it can be confusing due at first sight seems like we are assigning an *EventArgs* objeect to a *MovedEventArgs* variable (*MovedEventArgs*<-*EventArgs*), this case in OOP (Object Oriented programming) isnot valid, due it might throw a Traceback if a *MovedEventArgs* member is trying to be accessed in a *EventArgs*object.
632
632
633
-
However in this example isnot the case, the subscriber with*Callable[[object, EventArgs], None]* signature defines how the parameter objectis going to be treated by the callable, in this case, the parameter will be used/treated as an *EventArgs*, and the event will provide a *MovedEventArgs*object to the callable so in reallity we are asigning a *MovedEventArgs*object to an *EventArgs* variable (*EventArgs*<-*MovedEventArgs*) which by polimorfism will not cause any issue trying to access any of the *EventArgs* members in a *MovedEventArgs*object.
633
+
However in this example isnot the case, the subscriber with*Callable[[object, EventArgs], None]* signature defines how the parameter objectis going to be treated by the callable, in this case, the parameter will be used/treated as an *EventArgs*, and the event will provide a *MovedEventArgs*object to the callable so in reallity we are assigning a *MovedEventArgs*object to an *EventArgs* variable (*EventArgs*<-*MovedEventArgs*) which by polymorphism will not cause any issue trying to access any of the *EventArgs* members in a *MovedEventArgs*object.
634
634
635
635
Next code block explains a general case for what was explained above (subscriber signatures accepted by an event).
0 commit comments