Skip to content

Commit

Permalink
added object copy example
Browse files Browse the repository at this point in the history
  • Loading branch information
marianoguerra committed May 31, 2010
1 parent dd46309 commit 4914363
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/objcopy.ifn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# example on how to pass information from one object to another one
obj1 = object(attr1, attr2, attr3)

obj2 = object(attr1, attr2, attr3, attr4, attr5)

@public
run = fn ()
O1 = obj1(1, 2, 3)
O2 = obj2(nil, nil, nil, nil, nil)

# should copy attr 1, 2, 3 and leave 4 and 5 as nil
O3 = obj.copy(O1, O2)

io.format("~p~n", [O3(to, rec)])

O4 = O3(setattr4, true)(setattr5, atom)

# should copy attr 1, 2 and 3
O5 = obj.copy(O4, obj1(nil, nil, nil))

io.format("~p~n", [O5(to, rec)])

0 comments on commit 4914363

Please sign in to comment.