This file contains hidden or 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
| IRCBot: class { | |
| initialize: (server, channel, nick) { | |
| .server, .channel, .nick: server, channel, nick | |
| } | |
| connect: () { | |
| .socket: /* blablabla */ | |
| } | |
| send_message: (msg) { |
This file contains hidden or 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
| str: load_input // or whatever -- we have a string with newline-separated words | |
| // The worker task for mapreduce | |
| calculate_length_task: (task) { | |
| message: task.pop // Blocks until there is a message | |
| if message = "get_length" // Operator = overloaded for Message class | |
| task.yield message.args[0].length | |
| else | |
| task.yield null | |
| end |
This file contains hidden or 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
| MyBase: class { | |
| .some_method: (a) { | |
| return a + 2 | |
| } | |
| } | |
| MyObject: class { | |
| .prototype: MyBase | |
| // Method 1 |
This file contains hidden or 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
| monkey_patch: { | |
| .my_new_method: () { lol } | |
| } | |
| if MyObject | |
| MyObject.instance_eval &monkey_patch | |
| else | |
| MyObject: class &monkey_patch | |
| end |
This file contains hidden or 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
| c = new Compiler({ | |
| debug: "gcc -O0 -g -Werror -Wall blabla", | |
| release: "gcc -Os -march=blabla blabla", | |
| }); | |
| c.add_files("*.c"); | |
| c.build(); |
This file contains hidden or 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
| Muh: class { | |
| .==: [other] { return self == other } | |
| do_something(.==) | |
| do_something .== | |
| } |
This file contains hidden or 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
| lals: [a, b] { | |
| return [muh] { muh + a + b } | |
| } | |
| print lals(2, 3)(9) // => 14 |
This file contains hidden or 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
| lalala: { | |
| throw "Hejsa" | |
| } | |
| muh: [] { | |
| try | |
| lalala | |
| catch x if String ~ x | |
| print("caught " + x) |
This file contains hidden or 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
| try | |
| // do something | |
| catch x | |
| // Handle exception | |
| else | |
| // An exception did not occur, or was not handled | |
| finally | |
| // Executed afterward in any case | |
| end |
This file contains hidden or 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
| Enumerate: Object | |
| Enumerate.__call__: [index] { index or self } | |
| Horse, Cow, Sheep, Chicken: Enumerate | |
| print Horse, Cow, Sheep, Chicken | |
| == Output == |
OlderNewer