From: Tom Stut Date: 2013-02-07T10:25:47+09:00 Subject: How to pass established/defined arrays into def method. I am trying to pass a defined array into a method. Ruby is interpreting it as an undefined local variable. Is there a way around this? Also, can a def method take a string and an array as parameters? player1 = [ ["Ten", 10, "Hearts"], ["King", 13, "Clubs"], ["Queen", 12, "Clubs"], ["Three", 3, "Clubs"], ["Ten", 10, "Clubs"], ["Jack", 10, "Clubs"], ["Ten", 2, "Diamonds"] ] def check_for_flush(suit, player) occurrences_of_suit = 0 player1.each do |subarray| if subarray[2].downcase == "#{suit}" occurrences_of_suit += 1 end end suit_hand = [] if suit >= 5 $player1.each do |subarray| if subarray[2] == "#{suit}" suit_hand << subarray end end end puts suit_hand.inspect end check_for_flush ('Clubs' ) check_for_flush ('Spades' ) check_for_flush ('Diamonds') check_for_flush ('Hearts') # I would also like to create a parameter player so that I can load different arrays into the method. -- Posted via http://www.ruby-forum.com/.