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 React = require("react"); | |
var ContentItemComponent = React.createClass({ | |
getInitialState: function() { | |
return { | |
contentItemId: "YOUR_CONTENT_ITEM_ID" | |
}; | |
}, |
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
# 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 } |