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
' Define an object class
class Object
var myadjective = "UNINITIALIZED"
def Describe(s)
myadjective = s
enddef
def Write()
print "I'm an ", myadjective, " object!";
enddef
endclass
print "Object List Test";;
' Create a list of object instances
Obj1 = new(Object)
Obj1.Describe("awesome")
Obj2 = new(Object)
Obj2.Describe("ugly")
ObjectList1 = List(Obj1, Obj2)
Obj1 = Nil
Obj2 = Nil
for X in ObjectList1
X.Write()
next
' Create another list of object instances
Obj3 = new(Object)
Obj3.Describe("unfathomable")
Obj4 = new(Object)
Obj4.Describe("ordinary")
ObjectList2 = List(Obj3, new(Object))
Obj3 = Nil
Obj4 = Nil
for X in ObjectList2
X.Write()
next
' Try to create a third list of object instances
ObjectList3 = List(new(Object), new(Object))
Here is the output from running the program:
Object List Test
I'm an awesome object!
I'm an ugly object!
I'm an unfathomable object!
I'm an ordinary object!
Error:
Ln 53, Col 35
Code 28, Abort Code 3
Message: Colon expected.
At line 42 it executes, but the second item in the list is Obj4, instead of an uninitialized fifth object instance.
At line 53 it fails.
The text was updated successfully, but these errors were encountered:
I experimented with lists of object instances:
Here is the output from running the program:
At line 42 it executes, but the second item in the list is Obj4, instead of an uninitialized fifth object instance.
At line 53 it fails.
The text was updated successfully, but these errors were encountered: