Ruby - Classes and Objects
What is wrong with this
to_s method?
class Item
def to_s
puts "Item description"
end
end
puts Item.new.to_sto_s method?
class Item
def to_s
puts "Item description"
end
end
puts Item.new.to_sto_s method should return a string, not print it.puts inside to_s prints the string but returns nil, so puts Item.new.to_s prints an empty line after.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions