From: "Mauricio Fernández" Date: 2002-12-02T05:05:41+09:00 Subject: Re: class << self (was Re: [FAQ] What do some of Ruby's symbols mean?) On Mon, Dec 02, 2002 at 02:19:46AM +0900, ts wrote: > >>>>> "H" == Hal E Fulton writes: > > H> But then, I find that "def self.meth" seems to > H> work fine... > > it work fine, but sometimes it exist a difference > > pigeon% cat b.rb > #!/usr/bin/ruby > class A > B = 12 > def self.a > puts "class method A::a : #{B}" > end > > class << self > B = 24 > def b > puts "class method A::b : #{B}" > end > end > end > > A::a > A::b > pigeon% > > pigeon% b.rb > class method A::a : 12 > class method A::b : 24 > pigeon% I knew there was a difference, but I really expected something "bigger". When I saw it, I thought "it introduces another scope, so what?". Is there something obvious I'm not seeing there? Or is the new scope all there's to see? -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com And 1.1.81 is officially BugFree(tm), so if you receive any bug-reports on it, you know they are just evil lies. -- Linus Torvalds