Jump To Constructor Push Property
When the "Parameters" list is empty, LW Python creates a new "Control" map for the class and the method that LW Python is jumping to. More formally,
if the following are true:
- expression state at time t = "call_build_args"
- Parameters List at time t = [ ]
- the expression at time t = Python constructor with name: class_name and arguments: args
- line number of method "__init__" of class class_name in (Class Map at time t) = line
then Control Map at time (t + 1) = [ entry 0: (pair ("class", class_name)), [ entry 1: (pair ("method", "__init__")), [ ] ] ]
if the following are true:
- expression state at time 25 = "call_build_args"
- Parameters List at time 25 = [ ]
- the expression at time 25 =
Person("John", "Smith", 25)
- line number of method "__init__" of class "Person" in (Class Map at time 25) = 2
then Control Map at time (25 + 1) = [ entry 0: (pair ("class", "Person")), [ entry 1: (pair ("method", "__init__")), [ ] ] ]
Try stepping through the simulator to see LW Python create a new "Control" map
Code Editor
class Person:
def __init__(self, first_name, last_name, age):
self.first_name = first_name
self.last_name = last_name
self.age = age
def age_in_months(self):
return self.age * 12
p = Person("John", "Smith", 25)
age = p.age_in_months()
LW Python State
Current Line | 1 | Current Tab | 0 | Time | 0 |
LW Python Simulator
Comments
Please log in to add comments