object.inspect not working

N

Navya Amerineni

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/
 
P

Patrik Maunus

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

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

James Edward Gray II

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
 
C

Caio Tiago Oliveira

James Edward Gray II, 28-05-2005 17:33:
inspect() returns a String which is often used to contain useful
debugging information. inspect() does not print that String.



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


:)




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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top