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 trialSY LOC
3,233 PointsCreate 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
class Product
attr_reader :name, :price
def initialize(name, price)
@name = name
@price = price
end
end
1 Answer
Salman Akram
Courses Plus Student 40,065 PointsHi 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
3,233 PointsSY LOC
3,233 Pointsgreat thank you. I over think it. I'm all over the place now.