4. Private! keep out!

Hi, i need help.

ruby tells me = “Oops, try again. It looks like your Dog class doesn’t have a private id method.”

here is my code :
def initialize(name, breed)
@name = name
@breed = breed
public

def bark
puts "Woof!"; end

private
def id
@id_number = 12345 ; end

end
end

1 Like

Make sure that the code in your post is identical to what you are running in the exercise.

Have you tested your code yourself? Does it seem like you have a private id method? Or what happens instead?
What information do you think would help you solve it?

@briceth,
Maybe…
http://stackoverflow.com/questions/10724221/where-to-place-private-methods-in-ruby
or
http://rubylearning.com/satishtalim/ruby_access_control.html

My code is not the same that the exercise but this is normal (instructions)

I dont know what to do, I just follow the instructions.

ok i did it :
class Dog
def initialize(name,breed)
@name = name
@breed = breed
end

public 

def bark
    puts "Woof!"
end

private

def id
    @id_number = 12345
end

end

2 Likes

class Dog
def initialize(name,breed)
@name=name
@breed=breed
end
public
def bark
puts “Woof!”

end
private
def id
    
 @id_number = 12345 

end
end