Forum: Ruby on Rails function reference

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
36a866aad2bd74afb2dd1396104418a3?d=identicon&s=25 David Nguyen (pppswing)
on 2008-11-13 16:21
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
D69d23d8e811e8ab2a8593380d6ede63?d=identicon&s=25 Jeff Emminger (jemminger)
on 2008-11-13 17:30
(Received via mailing list)
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 Nguyen <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.