# Pushing a record into an inst. vaariable

**URL:** <https://www.ruby-forum.com/t/pushing-a-record-into-an-inst-vaariable/147708>\
**Category:** Ruby\
**Created:** [September 4, 2008, 2:11pm UTC](https://www.ruby-forum.com/t/pushing-a-record-into-an-inst-vaariable/147708 "2008-09-04T14:11:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mosar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@mosar](https://www.ruby-forum.com/u/mosar)\
**Post date:** [September 4, 2008, 2:11pm UTC](https://www.ruby-forum.com/t/pushing-a-record-into-an-inst-vaariable/147708/1 "2008-09-04T14:11:02Z")

</div>

In a study(#31) published by the American Accounting Association, prof  
Ijiri  
has suggested a new way to treat accounting transactions by mean of  
asymetrical arrays and using wealth and income accounts instead of  
debit and credit accounts.  
In a little program I have tried to to use this kind of approach.My  
first program contains two classes: a class Account and and class  
Records.  
In the first part of my program (class Account part) I have introduced  
an initialize method and a balance methods.Furthermore there is  
another method whis is:

def add\_record(record)  
@records\<\< record  
end

The class Record part of the program contains these two lines of  
program:  
.  
.  
wealth\_account.add\_record(self)  
income\_acount.add\_record(self)

```
             .
             .

```

It means that the two objects wealth\_account and income\_account call  
the def add-record method.  
What I don’t understand is, if instead of the word record I put any  
word like a, x it is working properly. My question is: how does the  
program know that it has to go to the lines of code where I  
instantiate the records. As the user I know where I can find the  
records but there is no special flags which indicate these lines.

---

<div class="post-metadata">

**Author:** ![mosar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@mosar](https://www.ruby-forum.com/u/mosar)\
**Post date:** [September 4, 2008, 4:18pm UTC](https://www.ruby-forum.com/t/pushing-a-record-into-an-inst-vaariable/147708/2 "2008-09-04T16:18:19Z")

</div>

On Thu, Sep 4, 2008 at 8:04 AM, mosar [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In a study(#31) published by the American Accounting Association, prof  
> Ijiri  
> has suggested a new way to treat accounting transactions by mean of  
> asymetrical arrays and using wealth and income accounts instead of  
> debit and credit accounts.  
> As a former student of accounting this sounds rather interesting.

> The class Record part of the program contains these two lines of  
> program:  
> .  
> .  
> wealth\_account.add\_record(self)  
> income\_acount.add\_record(self)
> 
> ```
> .
> .
> 
> ```

If I had to take a wild guess, I assume these two lines are located  
inside an instance method of the Record class, correct?

> It means that the two objects wealth\_account and income\_account call  
> the def add-record method.  
> What I don’t understand is, if instead of the word record I put any  
> word like a, x it is working properly. My question is: how does the  
> program know that it has to go to the lines of code where I  
> instantiate the records. As the user I know where I can find the  
> records but there is no special flags which indicate these lines.

The program does not automatically create an instance of Record when  
you say “weath\_account.add\_record(self)”. At this point the instance  
of the record has to have already been constructed, if you’re  
referencing it with self.

This is very confusing, maybe you could try and clarify the situation  
a bit more? The more code you can post the better…

HTH,  
Michael G.
