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
Keeping the database clean
Arrays, loops, strings...
Similar virtual attributes and their getters/setter
Check type is XML Serializable
Serena Collage slideshow
Shortest regular expression for matching a subdomain.
Caching Methods
Tab-Switching in jQuery
Apache log file sorting
How to find max, min of three numbers?
Popular
Caching Methods
How to find max, min of three numbers?
Similar virtual attributes and their getters/setter
Shortest regular expression for matching a subdomain.
Arrays, loops, strings...
Check type is XML Serializable
Apache log file sorting
Tab-Switching in jQuery
Serena Collage slideshow
Keeping the database clean
Pastable version of
Rubyize this : 3rd edition
<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 5 6 7 8 9 10 11 12 13 14 15 16 17 18</pre> <pre class="sunburst"><span style="color:#E28964;">def</span> <span style="color:#89BDFF;">remove_insults</span>(<span style="color:#3E87E3;">input</span>) ctr <span style="color:#E28964;">=</span> <span style="color:#3387CC;">0</span> input.<span style="color:#89BDFF;">each</span> <span style="color:#E28964;">do </span>|<span style="color:#3E87E3;">word</span>| word <span style="color:#E28964;">=</span> word.<span style="color:#89BDFF;">downcase</span> <span style="color:#E28964;">if</span> word <span style="color:#E28964;">==</span> <span style="color:#65B042;"><span style="color:#65B042;">"</span>stupid<span style="color:#65B042;">"</span></span> <span style="color:#E28964;">||</span> word <span style="color:#E28964;">==</span> <span style="color:#65B042;"><span style="color:#65B042;">"</span>moron<span style="color:#65B042;">"</span></span> <span style="color:#E28964;">||</span> word <span style="color:#E28964;">==</span> <span style="color:#65B042;"><span style="color:#65B042;">"</span>dumbass<span style="color:#65B042;">"</span></span> <span style="color:#E28964;">||</span> word <span style="color:#E28964;">==</span> <span style="color:#65B042;"><span style="color:#65B042;">"</span>retard<span style="color:#65B042;">"</span></span> i<span style="color:#E28964;">=</span><span style="color:#3387CC;">0</span> word.<span style="color:#89BDFF;">length</span>.<span style="color:#89BDFF;">times</span> <span style="color:#E28964;">do</span> input[ctr][i,<span style="color:#3387CC;">1</span>] <span style="color:#E28964;">=</span> <span style="color:#65B042;"><span style="color:#65B042;">"</span>*<span style="color:#65B042;">"</span></span> i<span style="color:#E28964;">+=</span><span style="color:#3387CC;">1</span> <span style="color:#E28964;">end</span> <span style="color:#E28964;">end</span> ctr <span style="color:#E28964;">+=</span> <span style="color:#3387CC;">1</span> <span style="color:#E28964;">end</span> puts input.<span style="color:#89BDFF;">join</span>(<span style="color:#65B042;"><span style="color:#65B042;">"</span> <span style="color:#65B042;">"</span></span>).<span style="color:#89BDFF;">to_s</span> <span style="color:#E28964;">end</span> remove_insults <span style="color:#65B042;"><span style="color:#65B042;">"</span>you truly are a moron sir!<span style="color:#65B042;">"</span></span>.<span style="color:#89BDFF;">split</span>(<span style="color:#65B042;"><span style="color:#65B042;">"</span> <span style="color:#65B042;">"</span></span>) </pre> </div> </div> <a href="http://refactormycode.com/codes/74-rubyize-this-3rd-edition" 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>