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 trial

Ruby Ruby Booleans Ruby Booleans Nil

SY LOC
SY LOC
3,233 Points

Create a method on the Product class called sku. The sku method should return nil.

Hate to try to get a quick answer. What is it asking me to do?

class Product
  attr_reader :name, :price

  def initialize(name, price)
    @name = name
    @price = price
  end

end
returns.rb
class Product
  attr_reader :name, :price

  def initialize(name, price)
    @name = name
    @price = price
  end

end

1 Answer

Hi Sy Loc,

Create a method on the Product class called sku. The sku method should return nil.

The question basically say to create a "method", it means another new def / end, example below:

It should be called "sku" inside class Product

class Product
  attr_reader :name, :price

  def initialize(name, price)
    @name = name
    @price = price
  end

  #Example
  def sku
  end

end

Then the sku method should return nil

  #Example 2
  def sku
    return nil
  end

Hope that helps. :)

SY LOC
SY LOC
3,233 Points

great thank you. I over think it. I'm all over the place now.