Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
An attribute reader allows us to access variables in a class from outside that class. This is normally code we would have to write ourselves but Ruby gives us a shortcut in the form of an attribute reader.
Code Samples
class Name
attr_reader :first_name, :middle_name, :last_name
def initialize(title, first_name, middle_name, last_name)
@title = title
@first_name = first_name
@midde_name = middle_name
@last_name = last_name
end
end
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Benjamin Miller
4,344 Points2 Answers
-
Jonathan Walz
21,429 Points2 Answers
-
Andrew Carr
10,979 Points1 Answer
-
Joshua Atteberry
6,250 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up