Skip to content

Instantly share code, notes, and snippets.

var React = require("react");
var ContentItemComponent = React.createClass({
getInitialState: function() {
return {
contentItemId: "YOUR_CONTENT_ITEM_ID"
};
},
@nicc
nicc / gist:667755
Created November 8, 2010 14:40
Ruby's Enumerable #map and #select methods implemented with #inject
# The idea is just to illustrate that Ruby's #map and #select Enumerable methods
# are simply specific flavours of a fold operation, which Ruby implements as #inject.
# I've implemented #map and #select using #inject, and at the end I implemented #inject
# recursively. Ruby does #inject with Array#each, for very good reason. The recursive
# implementation is really just to illustrate the core Functional Programming concept
# which it derives from.
# We'll start simple. Map without applying a function:
[1,2,3,4,5].inject([]) {|memo, obj| memo << obj }