Created
April 19, 2013 19:07
-
-
Save hashmal/5422477 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
-------------------- | |
-- SUDDENLY OOP!! -- | |
-------------------- | |
-- Let's simulate a class... But since it's Shirka, it has to be different. | |
-- Let's make an AGENT! It would just be a task spawner... | |
(agent => User) [ -- `agent` would wrap a list inside a `receive`, and | |
-- handle chores/boilerplate around it | |
initialize [ -- Constructor method | |
<< << | |
"John" -- Tasks have their private stack, remember? | |
] | |
getName [ -- Simulate a method definition | |
>< << -> name | |
[ name ] | return | |
] | |
] | |
User [] new -- Spawn a new instance of the agent | |
[] :getName |<- -- Simulate a method invocation (just send a message) | |
puts -- Display the response | |
-- output: "John" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment