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
def x = ["y":{z-> println "Hello, ${z ?: 'World'}!"}].&y | |
x() // Hello, World! | |
x('Blah') // Hello, Blah! |
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
package blah | |
fun Main(args: List<String>) { | |
// ... your code goes here | |
} | |
external val process: dynamic | |
fun main(args: Array<String>) { | |
Main((process["argv"] as Array<String>).drop(2)) | |
} |
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
/************************* | |
First call it.next(): has the effect of starting the function, there is no yield waiting for input at this point, | |
therefore yield (line 13) passes back the value 6, and is now waiting for input | |
Second call it.next(12): yield (line 13) is paused and waiting for input, input is 12, therefore y is assigned the value 24 (2 * 12). | |
yield (line 14) passes back 8 (24(y) / 3), and is now waiting for input | |
Final call it.next(13): yield (line 14) is paused and waiting for input, input is 13, therefore z is assigned the value 13. | |
function returns x + y + z (5 + 24 + 13) = 42 | |
*************************/ |
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
fun HashMap<String, Any>.toJson(): Json { | |
val js = json() | |
this.forEach { (k, v) -> js.set(k, v) } | |
return js | |
} |
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
class Request { | |
constructor(protocol, host, requestHandler, responseHandler) { | |
this.protocol = protocol | |
this.host = host | |
this.requestHandler = requestHandler | |
this.responseHandler = responseHandler | |
} | |
_request(path, method, requestData, headers) { | |
return new Promise((resolve, reject) => { |