> Well, there is one difference -- the last one returns a different value for
> B.  I'm not sure what that buys you, but it's the thing that dumbfounds me
> the most about this issue.
>

Constant lookup works differently than other kinds of name resolution
in ruby. It walks up the *Lexical Scope* first, ,then the inheritance
chain and finally the top object.

Sprinkle 'Module.nesting' and you'll know the current lexical scope

class A
  B =12
  def self.a
    p Module.nesting #=> [A]
    puts "class method A::a : #{B}"
  end

  class << self   #=><Class:A> , creates new lexical scope
    B = 24
    def c
      p Module.nesting #=> [#<Class:A>, A]
      puts "class method A::c : #{B}"
    end
  end

end
A.a
A.c
puts "A::B : #{A::B}"

Not one of the more intuitive pieces in ruby.  ;-)

--Cheers
--Ragav