Take me home

Screwing up fixnum

Written by August Lilleaas, published August 31, 2008

As Chad Fowler said (somewhere in there): Many languages, such as Java, is made for stupid programmers, Ruby isn't.

He doesn't mean that Java programmers are stupid, he means that unlike Java, Ruby allows stupid people to do stupid things.

Look at what Ruby kindly allows you to do:

puts 10 / 2
# => 5

class Fixnum
  def /(other)
    self + other
  end
end

puts 10 / 2
# => 12

Undoubtably a very stupid thing to do. Java would have complained, because Java does not let you do stupid things like this. Ruby allows it, though.

This is good. It means Ruby is flexible, and that if you can dream it, you can do it.


Questions or comments?

Feel free to contact me on Twitter, @augustl, or e-mail me at august@augustl.com.