-
-
Save leejarvis/c7c443a40a57b94fb7be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object user { | |
int id, | |
string name, | |
} | |
def user::list, []user | |
def user::new(string name) user { | |
int id = len(user::list) + 1 | |
user u = user(id: id, name: name) | |
user::list.push(u) | |
return u | |
} | |
def user::at_id(int id) user { | |
return user::list[id - 1] | |
} | |
def user#print_name(user u) { | |
print(u.name) | |
} | |
user::new("Lee") | |
user::new("Bob") | |
for user u = user::list { | |
u.print_name() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment