Permalink
Browse files

Adding the Object#tap method from Ruby 1.9.

  • Loading branch information...
1 parent f434a99 commit 94a9a7be9f6ef8e5768e569fddba6677b952ca17 @jcoglan jcoglan committed Oct 29, 2008
Showing with 5 additions and 0 deletions.
  1. +5 −0 source/core/kernel.js
View
@@ -18,6 +18,11 @@ JS.Kernel = new JS.Module({
var self = this, cache = self.__mcache__ = self.__mcache__ || {};
if ((cache[name] || {}).fn === self[name]) return cache[name].bd;
return (cache[name] = {fn: self[name], bd: JS.bind(self[name], self)}).bd;
+ },
+
+ tap: function(block, scope) {
+ block.call(scope || null, this);
+ return this;
}
});

0 comments on commit 94a9a7b

Please sign in to comment.