# Function reference

**URL:** <https://www.ruby-forum.com/t/function-reference/153221>\
**Category:** Rails\
**Created:** [November 13, 2008, 4:21pm UTC](https://www.ruby-forum.com/t/function-reference/153221 "2008-11-13T16:21:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanight](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vanight](https://www.ruby-forum.com/u/vanight)\
**Post date:** [November 13, 2008, 4:21pm UTC](https://www.ruby-forum.com/t/function-reference/153221/1 "2008-11-13T16:21:58Z")

</div>

Hi

I’ve got 2 static functions (self.),  
playlist function is calling check\_movie function in a loop.

I need to have the results stored in myarray and myhash.

I don’t know how I can give references of myarray and myhash to  
check\_movie function so myarray and myhash are updated and not emptied  
everytime I loop.

def self.playlist  
myarray = new Array  
myhash = new Hash

Movie.find(:all).each do |movie|  
check\_movie(movie,myarray,myhash)  
end

#use of myarray and myhash

end

def self.check\_movie(movie,myarray,myhash)  
#fill myarray, fill myhash  
end

---

<div class="post-metadata">

**Author:** ![vanight](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/a698b9/32.png) [@vanight](https://www.ruby-forum.com/u/vanight)\
**Post date:** [November 13, 2008, 5:30pm UTC](https://www.ruby-forum.com/t/function-reference/153221/2 "2008-11-13T17:30:27Z")

</div>

return them

def self.playlist  
myarray = new Array  
myhash = new Hash

Movie.find(:all).each do |movie|  
myarray,myhash = check\_movie(movie,myarray,myhash)  
end

#use of myarray and myhash

end

def self.check\_movie(movie,myarray,myhash)  
#fill myarray, fill myhash

return myarray,myhash  
end

On Nov 13, 10:21 am, David N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
