Accessing a function without initalization

class Test
def hello
puts "hello"
end
end

Test.hello

How would I get this to work? I get undefined method ‘hello’ for
Test:Class

db

···


Jan 9 Fellowship reaches Lorien (LOTR)
Jan 9 Plough Monday
Jan 9 Day of the Martyrs in Panama
Jan 9 James Patrick Page (Led Zeppelin) is born in Middlesex, England, 1945

thanks everyone.
def Test.hello was the answer for everyone else who might wonder.

db

···

On Fri, Jan 10, 2003 at 03:55:32AM +0900, Daniel Bretoi wrote:

class Test
def hello
puts “hello”
end
end

Test.hello

How would I get this to work? I get undefined method ‘hello’ for
Test:Class

db


Jan 9 Fellowship reaches Lorien (LOTR)
Jan 9 Plough Monday
Jan 9 Day of the Martyrs in Panama
Jan 9 James Patrick Page (Led Zeppelin) is born in Middlesex, England, 1945


Jan 9 Fellowship reaches Lorien (LOTR)
Jan 9 Plough Monday
Jan 9 Day of the Martyrs in Panama
Jan 9 James Patrick Page (Led Zeppelin) is born in Middlesex, England, 1945

What about

a = Test.new()
a.hello

?

···

On Fri, Jan 10, 2003 at 03:55:32AM +0900, Daniel Bretoi wrote:

class Test
def hello
puts “hello”
end
end

Test.hello

How would I get this to work? I get undefined method ‘hello’ for
Test:Class

gminick (at) underground.org.pl http://gminick.linuxsecurity.pl/
[ “Po prostu lubie poranna samotnosc, bo wtedy kawa smakuje najlepiej.” ]

Daniel Bretoi wrote:

class Test
def hello
puts “hello”
end
end

Test.hello

How would I get this to work? I get undefined method ‘hello’ for
Test:Class

Try this:

 class Test
   def Test.hello
     puts "hello"
   end
 end

Hope this helps,

Lyle

thanks everyone.
def Test.hello was the answer for everyone else who might wonder.

I’ve noticed that self.hello works just as well. Are there any
disadvantages to this?
db

···

On Fri, Jan 10, 2003 at 04:10:59AM +0900, Daniel Bretoi wrote:

db

On Fri, Jan 10, 2003 at 03:55:32AM +0900, Daniel Bretoi wrote:

class Test
def hello
puts “hello”
end
end

Test.hello

How would I get this to work? I get undefined method ‘hello’ for
Test:Class

db


Jan 9 Fellowship reaches Lorien (LOTR)
Jan 9 Plough Monday
Jan 9 Day of the Martyrs in Panama
Jan 9 James Patrick Page (Led Zeppelin) is born in Middlesex, England, 1945


Jan 9 Fellowship reaches Lorien (LOTR)
Jan 9 Plough Monday
Jan 9 Day of the Martyrs in Panama
Jan 9 James Patrick Page (Led Zeppelin) is born in Middlesex, England, 1945


Jan 9 Fellowship reaches Lorien (LOTR)
Jan 9 Plough Monday
Jan 9 Day of the Martyrs in Panama
Jan 9 James Patrick Page (Led Zeppelin) is born in Middlesex, England, 1945

Smells like python, but it isn’t a disadvantage (at least) for me ;>

···

On Fri, Jan 10, 2003 at 04:16:22AM +0900, Daniel Bretoi wrote:

def Test.hello was the answer for everyone else who might wonder.
I’ve noticed that self.hello works just as well. Are there any
disadvantages to this?

gminick (at) underground.org.pl http://gminick.linuxsecurity.pl/
[ “Po prostu lubie poranna samotnosc, bo wtedy kawa smakuje najlepiej.” ]

See http://www.rubygarden.org/ruby?ClassMethods for more on this
matter. There’s no “disadvantage” as such, but it’s good for you to
know the various ways of defining class methods.

Gavin

···

On Friday, January 10, 2003, 6:16:22 AM, Daniel wrote:

On Fri, Jan 10, 2003 at 04:10:59AM +0900, Daniel Bretoi wrote:

thanks everyone.
def Test.hello was the answer for everyone else who might wonder.

I’ve noticed that self.hello works just as well. Are there any
disadvantages to this?
db