3 ms·
[2, 1] in [[1,2], [2, 1], [3, 5]] Does it handle this? CoffeeScript was a bit too close to JS to get this correct.
by rockdoe 12y ago
[2, 1] in [[1,2], [2, 1], [3, 5]]
Does it handle this? CoffeeScript was a bit too close to JS to get this correct.
- jdkanani 12y agoI just checked it. RapydScript generates very logical code than CoffeeScript. CoffeeScript: var ref; (ref = [2, 1]) === [1, 2] || ref === [2, 1] || ref === [3, 5] || ref === [3, 5]; RapydScript: function _$rapyd$_in(val, arr) { if (arr instanceof Array || typeof arr === "string") return arr.indexOf(val) != -1; else { if (arr.hasOwnProperty(val)) return true; return false; } } _$rapyd$_in([2,1], [[1,2], [2,1], [3,5], [3,5]]); One thing I worried about RapydScript is generated variables. Pre-compiler needs to be scope aware. I am not sure how difficult or feasible it would be.