Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
22
Task/Call-an-object-method/Red/call-an-object-method.red
Normal file
22
Task/Call-an-object-method/Red/call-an-object-method.red
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
;-object creation
|
||||
my-proto: object [
|
||||
val1: 2
|
||||
val2: 3
|
||||
set: func [arg1 arg2] [self/val1: arg1 self/val2: arg2]
|
||||
sum: func [][ return (val1 + val2)]
|
||||
]
|
||||
|
||||
;-create an instance
|
||||
my-obj1: copy my-proto
|
||||
;-calling internal method to get value
|
||||
print my-obj1/sum
|
||||
|
||||
;-create a new instance
|
||||
my-obj2: copy my-proto
|
||||
;- calling an internal mathod to set value
|
||||
my-obj2/set 1 1
|
||||
;-calling the get method
|
||||
print my-obj2/sum
|
||||
|
||||
;-calling the get method on the first object
|
||||
print my-obj1/sum
|
||||
Loading…
Add table
Add a link
Reference in a new issue