Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6682209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:40:45+00:00 2026-05-26T04:40:45+00:00

I feel this is fundamental to my understanding of Ruby and object-oriented programming in

  • 0

I feel this is fundamental to my understanding of Ruby and object-oriented programming in general, so I’m asking this fairly simplistic question here at the risk of looking foolish. I’ve been toying around with irb. I’ve created my first ever class:

$ irb
ruby-1.9.2-p290 :001 > class Person
ruby-1.9.2-p290 :002?>   attr_accessor :firstname, :lastname, :gender
ruby-1.9.2-p290 :003?>   end
 => nil 
ruby-1.9.2-p290 :004 > person_instance = Person.new
 => #<Person:0x007f9b7a9a0f70> 
ruby-1.9.2-p290 :005 > person_instance.firstname = "Bob"
 => "Bob" 
ruby-1.9.2-p290 :006 > person_instance.lastname = "Dylan"
 => "Dylan"
ruby-1.9.2-p290 :007 > person_instance.gender = "male"
 => "male"

So Person.new is my object, right? Or is my object the combination of class Person and the attributes I’ve defined for that class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:40:46+00:00Added an answer on May 26, 2026 at 4:40 am

    Your object is the result of running Person.new, which you’ve captured in person_instance.

    In ruby, attributes don’t actually exist until they are first written, so before person_instance.firstname = "Bob", your instance has no attributes. After executing this statement it has a @firstname attribute, but no others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel foolish asking such a fundamental question but it would be more foolish
I feel this might be a weird/stupid question, but here goes... In the question
I feel this is an awfully obtuse question to ask, but strangely, this problem
I feel this is not a very good question to post on SO, but
I feel like this is a stupid question because it seems like common sense
I feel like this is a dumb question and I'm missing something, but I
I feel like this is a stupid question, but I can't think of a
I feel like I'm missing a fairly fundamental concept to WPF when it comes
I sort of asked this question at the end of another post but feel
I feel like I don't understand something fundamental here. I've been working on memory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.