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!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Learning JS
Type Safety
Euler Problem 2 solution
Popular
Parsing of XML data has high CPU usage
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Active Record getting unique records
Breadth first cartesian product iterator
php refactoring
first BST
Learning JS
Too many if statements
clean the code
Pastable version of
Rubyize this : 6th edition
<pre class='prettyprint' language='ruby'>class VotingSystem #Hello, I am Rodger the old and unhappy programmer. the variable nbrOfVotes is an array of 2 dimensions. The first dimension contains the number of votes for the answer "YES, IT SUCKS"... and the other dimension contain the number of votes for the answer "NO, IT DOESN'T SUCK". In the near future there will be other possible answers... but I don't care! I retire in 2 days! @@nbrOfVotes = Array.new #The users who sent their vote arrive in this very top secret method!! (I retire in 2 days!) def receiveAVote(theVote) if theVote == "YES, IT SUCKS" @@nbrOfVotes[0] = 0 if @@nbrOfVotes[0].nil? @@nbrOfVotes[0] = @@nbrOfVotes[0] + 1 else if theVote == "NO, IT DOESN'T SUCK" @@nbrOfVotes[1] = 0 if @@nbrOfVotes[1].nil? @@nbrOfVotes[1] = @@nbrOfVotes[1] + 1 else puts "THIS IS NOT A VALID ANSWER YOU MORON... btw i retire in 2 days!" end end end #This is the function that compile ALL the votes... I retire in 2 days! def compileAllTheVotes for i in (0..1) if i == 0 @@nbrOfVotes[0] = 0 if @@nbrOfVotes[0].nil? puts "HERE IS THE NUMBER OF VOTES FOR 'YES IT SUCKS' : " + @@nbrOfVotes[0].to_s else if i == 1 @@nbrOfVotes[1] = 0 if @@nbrOfVotes[1].nil? puts "HERE IS THE NUMBER OF VOTES FOR 'NO IT DOESN'T SUCKS' : " + @@nbrOfVotes[1].to_s end end end end end</pre> <a href="http://www.refactormycode.com/codes/283-rubyize-this-6th-edition" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>