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
package org.vld.kotlin.language | |
class Demo(private val property: String = "Demo") { | |
fun runExample() { | |
// run > transformation function > this > returns new value | |
val string = "run Kotlin".run { | |
println(this) | |
"run Kotlin 1.2.20" | |
} |
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
var Parent = function(name) { // constructor | |
this.name = name; // own property | |
}; | |
// Function.prototype | |
(function(proto) { | |
// shared method | |
proto.toString = function() { return '** Parent ' + this.name; }; | |
})(Parent.prototype); |
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
var _ = require('lodash'); | |
var Promise = require('bluebird'); | |
var recursive = function(obj, proc, pred) { | |
pred = pred || _.partial(_.identity, true); | |
(function recurse(parent, val, key) { | |
_.isObject(val) ? _.map(val, _.partial(recurse, val)) | |
: pred(val) && (parent[key] = proc(val)); | |
})(null, obj); | |
}; |
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
var _ = require('lodash'); | |
var Success = function(success) { this.success = success; }; | |
var Failure = function(failure) { this.failure = failure; }; | |
var bindAll = function(fs) { | |
var bind = function(res, f) { | |
return res instanceof Success ? f(res.success) : res; | |
}; | |
var bindF = function(f) { return _.partial(bind, _, f); }; |