Ruby Class vs Instance Method

So, what is an instance variable and instance method?

class Album

def release_date=(date)
@release_date = date
end

def release_date
@release_date
end
end
album = Album.new
album.release_date = 1991
album.release_date
# => 1991

What is a class variable and class method?

def self.countend

Well that then raises another question, what is self?

class Album
@@album_count = 4

def self.count
@@album_count
end
end
# You call it by writing:
Album.count

--

--

--

A software engineering student at Flatiron School.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Fix ‘Failed To Load Resource’ Error In WordPress

19coders

The intersection of two arrays II solution ~ LeetCode

Sortings: Algorithms & Implementation & Analyze

How to Determine a Prime Number Efficiently

Integration of Artificial Intelligence (AI) on AWS Cloud

Do you know Hexadecimal to Binary Conversion?

The Shared Economy for Your IT

Basecamp 3: New feature round-up

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jessica Sewell

Jessica Sewell

A software engineering student at Flatiron School.

More from Medium

Adding a Star Rating with Turbo

Working with ruby C extensions on Mac

Learning Management System Project with Source Code -Ruby

Rails: Nesting Data with Custom Serializers using Active Model Serializers