Saturday, July 30, 2016

Classes in Lua

This is an adaptation of the code found here:

When run, the output looks like this:

kuyu@castor-ub:~/dkuyu/Dropbox/practice/lua/oop$ ./l.lua 
Calling constructor for table: 0x8a2160
Accessing key = deposit for table: 0x8a1df0; self = table: 0x8a2160
Account:deposit(): self = table: 0x8a1df0
Accessing key = get_balance for table: 0x8a1df0; self = table: 0x8a2160
Account:get_balance(): self = table: 0x8a1df0
a's balance: 100
Calling constructor for table: 0x8a2160
Accessing key = deposit for table: 0x89a4a0; self = table: 0x8a2160
Account:deposit(): self = table: 0x89a4a0
Accessing key = balance for table: 0x89a4a0; self = table: 0x8a2160
Account:balance = 0
Accessing key = withdraw for table: 0x89a4a0; self = table: 0x8a2160
Account:withdraw(): self = table: 0x89a4a0
Accessing key = get_balance for table: 0x89a4a0; self = table: 0x8a2160
Account:get_balance(): self = table: 0x89a4a0
b's balance: 60
kuyu@castor-ub:~/dkuyu/Dropbox/practice/lua/oop$ 



No comments:

Post a Comment