Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialblake littleton
14,255 PointsThe "dump" method was not called.
I've tried a couple of things with this code and I'm still not seeing what im doing wrong. Any suggestions?
class Name
attr_accessor :first, :last
def initialize(first, last)
@first = first
@last = last
end
end
def Marshal.dump
[@first, @last]
end
name = Name.new("First", "Last")
1 Answer
Ari Misha
19,323 PointsHiya Blake! You dont have to additionally define a method named "dump" or "Marshal". "Marshal" is a built-in Ruby module, and this module has a method named "dump" and it takes an arguement called "obj", where obj is an object. And objects are intantiated on classes. Here is how your code should look like:
class Name
attr_accessor :first, :last
def initialize(first, last)
@first = first
@last = last
end
end
name = Name.new("First", "Last")
Marshal.dump(name)
Check out the syntax for "dump" method:
blake littleton
14,255 Pointsblake littleton
14,255 PointsOh now I get it. Thanks!