Object.inspect not working

hi all,

i am very new to Ruby.
I stared writing very basic programs
The below is one of my program
class Song
  def initialize(name, artist, duration)
    @name=name
    @artist=artist
    @duration=duration
  end
  def myclass_function
    puts "this is my first class"
  end
end
class1=Song.new("Navya","Teja",540)
class1.myclass_function
class1.inspect

i am not getting any any output for the statement
class1.inspect

what might be possible correction
please help

Navya.

···

__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new Resources site
http://smallbusiness.yahoo.com/resources/

Object#inspect returns a string, it does not print out the result.
try:
puts class1.inspect

···

On Sun, 29 May 2005 05:15:35 +0900, Navya Amerineni wrote:

class1=Song.new("Navya","Teja",540)
class1.myclass_function
class1.inspect

i am not getting any any output for the statement
class1.inspect

what might be possible correction
please help

hi all,

i am very new to Ruby.
I stared writing very basic programs
The below is one of my program
class Song
    def initialize(name, artist, duration)
        @name=name
        @artist=artist
        @duration=duration
    end
    def myclass_function
        puts "this is my first class"
    end
end
class1=Song.new("Navya","Teja",540)
class1.myclass_function
class1.inspect

i am not getting any any output for the statement
class1.inspect

inspect() returns a String which is often used to contain useful debugging information. inspect() does not print that String.

what might be possible correction

You need to ask Ruby to print the String to the screen. Try changing the last line to:

puts class1.inspect

Hope that helps.

James Edward Gray II

···

On May 28, 2005, at 3:15 PM, Navya Amerineni wrote:

James Edward Gray II, 28-05-2005 17:33:

···

On May 28, 2005, at 3:15 PM, Navya Amerineni wrote:

hi all,

i am very new to Ruby.
I stared writing very basic programs
The below is one of my program
class Song
    def initialize(name, artist, duration)
        @name=name
        @artist=artist
        @duration=duration
    end
    def myclass_function
        puts "this is my first class"
    end
end
class1=Song.new("Navya","Teja",540)
class1.myclass_function
class1.inspect

i am not getting any any output for the statement
class1.inspect

inspect() returns a String which is often used to contain useful debugging information. inspect() does not print that String.

what might be possible correction

You need to ask Ruby to print the String to the screen. Try changing the last line to:

puts class1.inspect

or even

p class1

:slight_smile:

____________________________________________________
Yahoo! Mail, cada vez melhor: agora com 1GB de espaço grátis! http://mail.yahoo.com.br