Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
More Jobs
Recent
Closure scoping issue
Parse HTTP Accept headers
Int32 Quick Parser
Find the file with the highest mtime in a directory
While loop to get unique value
ruby metaprogramming
includes_all?
Expanding input list using jQuery
Streamline attaching onPaste behavior to fields
Which is more readable? Math.* or if (...)
Popular
Int32 Quick Parser
ruby metaprogramming
includes_all?
Find the file with the highest mtime in a directory
Parse HTTP Accept headers
Closure scoping issue
While loop to get unique value
Command Pattern from Head First Design Patterns book.
Which is more readable? Math.* or if (...)
Streamline attaching onPaste behavior to fields
Pastable version of
Squash a collection.
<div style="overflow:auto;border:solid 1px #ccc;background:#000;color:#F8F8F8"> <div class="section"> <pre style="float:left;margin:0 10px;border-right:0;color:#666;">1 2 3 4</pre> <pre class="sunburst"><span style="color:#E28964;">def</span> <span style="color:#89BDFF;">all_shops</span>(<span style="color:#3E87E3;">products</span>) ids <span style="color:#E28964;">=</span> [] products.<span style="color:#89BDFF;">collect</span> { |<span style="color:#3E87E3;">product</span>| product.<span style="color:#89BDFF;">shops</span> }.<span style="color:#89BDFF;">flatten</span>.<span style="color:#89BDFF;">reject</span> { |<span style="color:#3E87E3;">s</span>| <span style="color:#E28964;">if</span> ids.<span style="color:#89BDFF;">include?</span>(s.<span style="color:#89BDFF;">id</span>); <span style="color:#3387CC;">true</span>; <span style="color:#E28964;">else</span>; ids.<span style="color:#89BDFF;">push</span>(s.<span style="color:#89BDFF;">id</span>); <span style="color:#3387CC;">false</span>; <span style="color:#E28964;">end</span> } <span style="color:#E28964;">end</span> </pre> </div> </div> <a href="http://refactormycode.com/codes/352-squash-a-collection" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://refactormycode.com/images/small_logo.gif" style="border:0" /></a>