YAD wrote: > Trying to write one function that will find a > full row or column in a 2D array (for tic-tac-toe). I'm making an assumption here, that you want to find a winning pattern. ---------------------------------------------------------- #! /usr/bin/ruby grid = [ ['X',' ','O'], [' ','O',' '], ['O',' ','X'] ] def test_rows(array) array.each do |row| return row.first if (row.first != ' ' && row.uniq.size == 1) end return false end def test_diagonals(array) c = array[1][1] if(c != ' ') return c if((c == array[0][2] && c == array[2][0]) \ || (c == array[0][0] && c == array[2][2])) end return false end def find_winner(array) w = test_rows(array) \ || test_rows(array.transpose) \ || test_diagonals(array) puts "found winning row for player \"#{w}\"" if w end find_winner(grid) Output: found winning row for player "O" -- Paul Lutus http://www.arachnoid.com