Skip to content

Instantly share code, notes, and snippets.

@lukemorton
Last active November 1, 2015 17:55
Show Gist options
  • Save lukemorton/755cd25ebf2904afd31b to your computer and use it in GitHub Desktop.
Save lukemorton/755cd25ebf2904afd31b to your computer and use it in GitHub Desktop.
Reasons why I prefer ruby and clojure to js
className () {
let className = 'purchase_orders_table';
if (this.state.sticky) className += '--sticky';
return className;
}
(defn class-name [state]
(string "purchase_orders_table"
(if (state :sticky) ("--sticky"))))
def class_name
"purchase_orders_table#{'--sticky' if @state.sticky?}"
end
renderCols () {
const cellWidths = this.cellWidths();
let cols = [];
for (let i = 0; i < cellWidths.length; i++) {
cols.push((
<col key={i} style={{ width: cellWidths[i] }} />
));
}
return cols;
}
(defn render-columns []
(map-indexed #(col {:key %1 :style {:width %2}}) (cell-widths)))
def render_columns
cell_widths.each_with_index.map do |width, i|
col(key: i, style: { width: width })
end
end
function removeEmptyKeys(object) {
for (let key in object) {
if (object.hasOwnProperty(key) && (object[key] == null || object[key] === '')) {
delete object[key];
}
}
return object;
}
(defn remove-empty-keys [map]
(into {} (filter #(not (nil? (% 1))) map)))
def remove_empty_keys(hash)
hash.keep_if { |_, v| !v.nil? }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment