Skip to content

Instantly share code, notes, and snippets.

@olliebun
Created November 3, 2013 23:22
Show Gist options
  • Save olliebun/7295983 to your computer and use it in GitHub Desktop.
Save olliebun/7295983 to your computer and use it in GitHub Desktop.
Coffeecript's list comprehension compilation.. crazy.
validate: (attrs, options) ->
missing = [attr for attr in required if attrs[attr] is null]
if missing.length > 0
return "Missing #{missing.join(', ')}"
validate: function(attrs, options) {
var attr, missing;
return missing = [
(function() {
var _i, _len, _ref, _results;
if (attrs[attr] === null) {
_ref = ['project', 'ref', 'context'];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
attr = _ref[_i];
_results.push(attr);
}
return _results;
}
})()
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment