News for hackers. Stuff that matters.
Re:Yehuda Katz's 10 Favorite Things About Ruby by tptacek on Monday August 24, 2009 @02:55PM (#782943)
Not everything in Ruby is a full-fledged class; for instance, you can't extend Fixnum.

[I am apparently completely wrong here].

Re:Yehuda Katz's 10 Favorite Things About Ruby by jcapote on Monday August 24, 2009 @03:08PM (#782975)
Says who?

irb(main):001:0> class Fixnum

irb(main):002:1> def doit

irb(main):003:2> puts "hey"

irb(main):004:2> end

irb(main):005:1> end

=> nil

irb(main):006:0> 2.doit

hey

=> nil

irb(main):007:0>

Re:Yehuda Katz's 10 Favorite Things About Ruby by jeremymcanally on Monday August 24, 2009 @04:19PM (#783220)
Yup. Perhaps he was thinking of Python, where his assertion is true.
Re:Yehuda Katz's 10 Favorite Things About Ruby by blasdel on Monday August 24, 2009 @09:07PM (#783853)
Not true in Python either since new-style classes unified types and classes.
Re:Yehuda Katz's 10 Favorite Things About Ruby by nudded on Monday August 24, 2009 @03:48PM (#783109)

  class Fixnum
    def +(other)
      42
    end
  end
3 + 2 => 42
Re:Yehuda Katz's 10 Favorite Things About Ruby by railsjedi on Monday August 24, 2009 @04:49PM (#783314)
I try to sneak this into all of my rubygems
Re:Yehuda Katz's 10 Favorite Things About Ruby by tremendo on Monday August 24, 2009 @05:07PM (#783361)
Ah The Answer. BTW, it crashes my IRB (Ruby 1.9.1/Win)
Re:Yehuda Katz's 10 Favorite Things About Ruby by judofyr on Monday August 24, 2009 @05:06PM (#783358)
You're partly right. Fixnums don't have a metaclass (or virtualclass) because they're actually "immediate". So you can't say 123.extend(Something) because 123 isn't really a full Object.
Re:Yehuda Katz's 10 Favorite Things About Ruby by wycats on Monday August 24, 2009 @05:08PM (#783364)
That's just to say that there aren't multiple "2"s. But 2 itself is still an object, pointing at its Fixnum class, which has all the normal Class and Object semantics.
Re:Yehuda Katz's 10 Favorite Things About Ruby by tptacek on Monday August 24, 2009 @09:04PM (#783849)
Fixnums have a different representation in the interpreter (at least in 1.8 MRI) than normal objects do, which is probably what tripped me up here.
Re:Yehuda Katz's 10 Favorite Things About Ruby by wycats on Tuesday August 25, 2009 @12:04PM (#785092)
Yeah. Conceptually, you can think of the difference as whether or not there can be two copies of something. There can only be one copy of a Symbol, Fixnum, true, false, and nil. This means that true == true, and true.dup #=> error.